我有以下代码
$criteria=new CDbCriteria;
$criteria->with = array('owner'=>array('select'=>array('*','payment_info'=>'payment_account')));
工作正常,但当我添加concat
$criteria->with = array('owner'=>array('select'=>array('*','payment_info'=>'concat(payment_account)')));
它引发了我的错误
Active record "User" is trying to select an invalid column "concat(payment_account)". Note, the column must exist in the table or be an expression with alias.
如何为它提供别名?
答案 0 :(得分:0)
尝试给它一个别名,例如:
$criteria->with = array('owner'=> array('select'=> array('*','payment_info'=>'concat(payment_account) as conc')));
之前我没有遇到过这种方法。