Hello!
I’ve tried to get it on my own, tried IRC channel, tried the russian comunity…, so here is the deal:
The sources:
The Transactions View - http://pastebin.com/fBWBk0ZK
The Transactions Controller - http://pastebin.com/9d9UGhCc
The Transactions Model - http://pastebin.com/ePpRQC0Y
The Accounts model - http://pastebin.com/uSbwVBxU
The TransactionsVouchers model - http://pastebin.com/iD9BU2pf
When I load the grid - everything works fine. But when I try to filter by trnvouchers.tvc_code field, I get the error:
CDbException
Description
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'trnvouchers.tvc_code' in 'where clause'
Source File
C:\development\yii-1.1.2\framework\db\CDbCommand.php(375)
00363: }
00364:
00365: if($this->_connection->enableProfiling)
00366: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00367:
00368: return $result;
00369: }
00370: catch(Exception $e)
00371: {
00372: if($this->_connection->enableProfiling)
00373: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00374: Yii::log('Error in querying SQL: '.$this->getText().$par,CLogger::LEVEL_ERROR,'system.db.CDbCommand');
00375: throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
00376: array('{error}'=>$e->getMessage())));
00377: }
00378: }
00379: }
Stack Trace
#0 C:\development\yii-1.1.2\framework\db\CDbCommand.php(265): CDbCommand->queryInternal('fetchAll', 2, Array)
#1 C:\development\yii-1.1.2\framework\db\ar\CActiveFinder.php(739): CDbCommand->queryAll()
#2 C:\development\yii-1.1.2\framework\db\ar\CActiveFinder.php(413): CJoinElement->runQuery(Object(CJoinQuery))
#3 C:\development\yii-1.1.2\framework\db\ar\CActiveFinder.php(85): CJoinElement->find(Object(CDbCriteria))
#4 C:\development\yii-1.1.2\framework\db\ar\CActiveRecord.php(1178): CActiveFinder->query(Object(CDbCriteria), true)
#5 C:\development\yii-1.1.2\framework\db\ar\CActiveRecord.php(1244): CActiveRecord->query(Object(CDbCriteria), true)
#6 C:\development\yii-1.1.2\framework\web\CActiveDataProvider.php(103): CActiveRecord->findAll(Object(CDbCriteria))
#7 C:\development\yii-1.1.2\framework\web\CDataProvider.php(120): CActiveDataProvider->fetchData()
#8 C:\development\yii-1.1.2\framework\zii\widgets\CBaseListView.php(99): CDataProvider->getData()
#9 C:\development\yii-1.1.2\framework\zii\widgets\grid\CGridView.php(220): CBaseListView->init()
#10 C:\development\yii-1.1.2\framework\web\CBaseController.php(148): CGridView->init()
#11 C:\development\yii-1.1.2\framework\web\CBaseController.php(173): CBaseController->createWidget('zii.widgets.gri...', Array)
#12 C:\development\ukash-admin\protected\views\transactions\index.php(88): CBaseController->widget('zii.widgets.gri...', Array)
#13 C:\development\yii-1.1.2\framework\web\CBaseController.php(119): require('C:\development\...')
#14 C:\development\yii-1.1.2\framework\web\CBaseController.php(88): CBaseController->renderInternal('C:\development\...', Array, true)
#15 C:\development\yii-1.1.2\framework\web\CController.php(748): CBaseController->renderFile('C:\development\...', Array, true)
#16 C:\development\yii-1.1.2\framework\web\CController.php(687): CController->renderPartial('index', Array, true)
#17 C:\development\ukash-admin\protected\controllers\TransactionsController.php(119): CController->render('index', Array)
#18 C:\development\yii-1.1.2\framework\web\actions\CInlineAction.php(32): TransactionsController->actionIndex()
#19 C:\development\yii-1.1.2\framework\web\CController.php(300): CInlineAction->run()
#20 C:\development\yii-1.1.2\framework\web\CController.php(278): CController->runAction(Object(CInlineAction))
#21 C:\development\yii-1.1.2\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#22 C:\development\yii-1.1.2\framework\web\CWebApplication.php(320): CController->run('index')
#23 C:\development\yii-1.1.2\framework\web\CWebApplication.php(120): CWebApplication->runController('transactions/in...')
#24 C:\development\yii-1.1.2\framework\base\CApplication.php(135): CWebApplication->processRequest()
#25 C:\development\ukash-admin\index.php(12): CApplication->run()
#26 {main}
The SQL looks like this:
SELECT `t`.`trn_id` AS `t0_c0`,
`t`.`trn_started_on` AS `t0_c1`, `t`.`trn_finished_on` AS `t0_c2`,
`t`.`trn_total` AS `t0_c3`, `t`.`trn_total_real` AS `t0_c4`,
`t`.`trn_status` AS `t0_c5`, `t`.`trn_error_code` AS `t0_c6`,
`t`.`trn_email` AS `t0_c7`, `t`.`trn_by_account` AS `t0_c8`,
`t`.`trn_purse` AS `t0_c9`, `t`.`trn_paysystem` AS `t0_c10`, `t`.`trn_rate`
AS `t0_c11`, `t`.`trn_wm_id` AS `t0_c12`, `t`.`trn_system` AS `t0_c13`,
`t`.`trn_ip` AS `t0_c14`, `account`.`uac_id` AS `t2_c0`,
`account`.`uac_login` AS `t2_c1`, `account`.`uac_password` AS `t2_c2`,
`account`.`uac_active` AS `t2_c3`, `account`.`uac_last_action` AS `t2_c4`,
`account`.`uac_in_use` AS `t2_c5` FROM `transactions` `t` LEFT OUTER JOIN
`ukash_accounts` `account` ON (`t`.`trn_by_account`=`account`.`uac_id`)
WHERE (trnvouchers.tvc_code=:ycp0) ORDER BY trn_started_on DESC LIMIT 20
As you can see there is no transaction_vouchers table joined. But the log shows that the agregation query (self::STAT relation) works just fine
SELECT COUNT(DISTINCT `t`.`trn_id`) FROM
`transactions` `t` LEFT OUTER JOIN `transaction_vouchers` `trnvouchers` ON
(`trnvouchers`.`tvc_trn_id`=`t`.`trn_id`) LEFT OUTER JOIN `ukash_accounts`
`account` ON (`t`.`trn_by_account`=`account`.`uac_id`) WHERE
(trnvouchers.tvc_code=:ycp0)
Someone has any ideas how to fix this?