2013-01-10 10:22:06| 分类: yii之数据库操作 |字号 订阅
YII中默认的主表别名为t,看看下面的代码就知道它烦什么变态了,哎,纠结了我很久。
$criteria = new CDbCriteria();
$criteria->select = 't.AddUserId,t.AddUser,domain_id,tId,t.TaskID,t.Title,t.Amount,unCode,tTimeAdd,t.TimeStart,t.TimeEnd';
$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);
转载于:https://www.cnblogs.com/ldms/archive/2013/04/26/3045411.html