我創建了一個標準:Yii的CDbCriteria添加列
$ids = array(1,2,3);
$criteria = new CDbCriteria;
$criteria->select = 'SUM(quantity) as quan';
$criteria->with = array('order');
$criteria->condition="order.customer = ".Yii::app()->user->id." AND order.status_id <> 4 AND order.status_id <> 3 AND order.type = 0";
$criteria->addInCondition("product_id", $ids);
$order_prod = OrderProduct::model()->find($criteria);
但是當我運行此我得到錯誤:
1140 In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'als.t.id'; this is incompatible with sql_mode=only_full_group_by. The SQL statement executed was: SELECT SUM(quantity) as quan,
t
.id
ASt0_c0
,order
.id
ASt1_c0
,order
.phone
ASt1_c1
,order
.t1_c2
.
在標準選擇我只使用量的總和。
它這個完整的查詢?顯示完整查詢 – user1234