我在event.deleted_at
方法模型中添加了来自连接属性(event.status
,defaultScope
)的参数:
public function defaultScope()
{
return array(
'condition'=>'
lp_deleted_at is NULL
AND event.e_deleted_at IS NULL
AND event.status = TRUE
'
);
}
创建条件时最后一行(addSearchCondition
)出错:
$criteria=new CDbCriteria;
$criteria->with = array(
'lokasi_pengamatan'=>array('select'=>'lokasi_pengamatan.nama','together'=>true),
'event'=>array('select'=>'event.id_event','together'=>true)
$criteria->addSearchCondition('lokasi_pengamatan.nama', '%'.$this->lokasi_pengamatan.'%', false, 'AND', 'ILIKE');
错误消息
Undefined table: 7 ERROR: missing FROM-clause entry for table "event"
答案 0 :(得分:0)
我通常使用CDbCriteria编写SQL有点不同:
private function searchByUser(){
$criteria = new CDbCriteria;
$criteria->select = 'QuestionForm.*';
$criteria->addCondition('QuestionForm.user_id = $this->user_id');
return $this->with(array('QuestionForm'))->findAll($criteria);
}