Reputation: 644
I want to set the condition which shows all vehicles where the title_recieved
is null
.
->andFilterWhere(['=', 'tr.title_recieved', null])
->andFilterWhere(['is', 'tr.title_recieved', null])
->andFilterWhere(['is', [ 'tr.title_recieved', null]])
I've tried all the available options, the is null
condition works in andWhere
, but not in andFilterWhere
.
Upvotes: 2
Views: 3547
Reputation: 65
It can be done like this
$query->andFilterWhere(['IS', 'tr.title_recieved', new \yii\db\Expression('NULL')]);
Upvotes: 1
Reputation: 49
**As per yii2 doc andFilterWhere() Adds an additional WHERE condition to the existing one but ignores empty operands.
The new condition and the existing one will be joined using the 'AND' operator.
This method is similar to andWhere(). The main difference is that this method will remove empty query operands. As a result, this method is best suited for building query conditions based on filter values entered by users. From doc http://www.yiiframework.com/doc-2.0/yii-db-querytrait.html#andFilterWhere()-detail **
Upvotes: 1
Reputation: 5721
Try With This :
->andFilterWhere('tr.title_recieved is NULL');
Upvotes: 2
Reputation: 342
Use andWhere on query liek this.
->andWhere(['tr.title_recieved' => null]);
Upvotes: 6