Answer the question
In order to leave comments, you need to log in
How to make a query to the database in Yii2?
Hello. you need to make the following query using Yii2
SELECT * FROM table WHERE (id= '$id') AND (blocked = 1 or blocked = null )
$model2 = Table::find()->where(['id' => $model->id])->andWhere(['blocked' => null])->orWhere(['blocked' => '1'])->all();
Answer the question
In order to leave comments, you need to log in
where('id=:id and (blocked=1 or blocked is null)')->bind(':id', $id')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question