$data = \app\models\Events::find()->
where(['event_code''event_name'[] =>$_POST['event_code''event_name'] ])->all();
return $this->render('search',['data'=>$data]);
我需要在event_code
和event_name
进行搜索。我该怎么办?
答案 0 :(得分:0)
您可以使用andWhere
添加多个条件
$data = \app\models\Events::find()->where(['=','event_code',$_POST['event_code']])->andWhere(['=','event_name',$_POST['event_name']])->all();
答案 1 :(得分:0)
试试这个:
$data = \app\models\Events::find()->where(['event_code' => $_POST['event_code'], 'event_name' => $_POST['event_name']])->all();