如何从加入请求(Yii1)向模型添加属性?

时间:2016-08-05 11:06:04

标签: php yii

我的代码是:

$criteria = new MyCDbCriteria;                
$criteria->select = 't.id, acc.server_account, t.registration_date, lac.login, t.summ, t.input, t.output, t.lot, t.options_sum, t.profit';
$criteria->join = 'join `accounts` acc on (t.account_id = acc.id) join `users` u on (acc.user_id = u.id) join `leads_and_clients` lac on (u.login = lac.login)';
$records = PartnersReport::model()->findAll($criteria);
foreach ($records as $record) {
    foreach ($record->attributes as $key => $val) {
        $return['values'][$record->id][$key] = $val;
    }
}

问题:没有"加入" server_account中的$record->attributes等属性。如何添加?

1 个答案:

答案 0 :(得分:0)

创建一个属性PartnersReport :: server_account并将其用作SELECT中的别名:

$ criteria-> select =' t.id,acc.server_account AS server_account,t.registration_date,lac.login,t.summ,t.input,t.output,t.lot,t。 options_sum,t.profit';