$criteria = new CDbCriteria();
$criteria->select = 'table_name,model_id,sum(amount) total';
$criteria->group = 'table_name,model_id';
$criteria->addCondition("$nIdcId=4");//也可以$criteria->condition = "$nIdcId=4";
$aResult = accessory_info::model()->findAll($criteria);
$c = new CDbCriteria();
$c->select = 't.id, t.created_at, t.outsource_id, t.user_id, t.operate, t.content';
$c->join = 'LEFT JOIN outsource ON outsource.id=t.outsource_id';
$c->condition = 'outsource.idc_id IN(' . implode(',', $idc_ids) . ')';
if($last_log_id) {
$c->condition .= " AND t.id > $last_log_id";
}
$c->limit = 20;
$c->order = 't.id DESC';
$logs = OutsourceProcessLog::model()->findAll($c);