0

我有以下代码

$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. 

如何为其提供别名?

4

1 回答 1

0

尝试给它一个别名,例如:

$criteria->with = array('owner'=> array('select'=> array('*','payment_info'=>'concat(payment_account) as conc')));

我以前用过这种方法没有问题。

于 2012-04-18T14:10:36.420 回答