我在Yii有关系:
public function relations() {
return array(
'applicant' => array(
self::BELONGS_TO,
'ApplicantProfile',
array('applicant_id' => 'id'),
),
'filePair' => array(
self::BELONGS_TO,
'DocumentCategoryFile',
array('file_pair_id' => 'id'),
'joinType' => 'inner join'
)
);
}
我如何在addCondition
中为申请人创建CDbCriteria()
,例如我想要is_deleted = 0
。我试了$criteria->with = array('applicant' => array('join'=>'left join','condition'=>'
aplicant .is_deleted = 0'));
但我有sql语法错误
感谢
答案 0 :(得分:1)
试试这个 -
$criteria = new CDbCriteria();
$criteria->with = array('applicant');
$criteria->together = true;
$criteria->addCondition('applicant.is_deleted=0');
您应该参考链接here以了解如何使用它。