作个笔记,关联表的查询条件要写在with()之中
$condition='';
if(isset($_GET['type']))
{
$condition = 'audit_by_unit='.intval($_GET['type']);
}
$model=new CActiveDataProvider('Enrollment',array(
'criteria'=>array(
'condition'=>$condition,
'order'=>'create_time DESC',
'with'=>array('exam'=>array('condition'=>'exam.audit_user_id='.Yii::app()->user->id)),
),
));
==============================
比如:
$Art1s=Articles::model()->with('cate')->findAll(array('condition'=>'cate.id=2'));