YII中默认的主表别名为t,看看下面的代码就知道它烦什么变态了,哎,纠结了我很久。
$criteria = new CDbCriteria();
$criteria->select = ‘tAddUserId,tAddUser,domain_id,tId,tTaskID,tTitle,tAmount,unCode,tTimeAdd,tTimeStart,tTimeEnd’;
$criteria->condition = ‘t.domain_id > 0 ‘;
$criteria->limit = 2000;
$arr_with = array(
‘TaskSyn’=>array(‘select’=>’is_task_syn’,’condition’=>’TaskSyn.is_task_syn=0 OR TaskSyn.is_task_syn IS NULL’),
‘User’=>array(‘select’=>’uId’,’condition’=>’ User.uId=110′),
); //增加附加表所需条件。
$incomeTasks = Tasks::model()->with($arr_with)->findAll($criteria);