0

我在方法模型中添加了来自连接属性 ( 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"
4

1 回答 1

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);
}
于 2013-05-17T00:53:09.303 回答