How to do IS NULL and IS NOT NULL with Yii 2 ActiveRecord?

后端 未结 5 2035
情话喂你
情话喂你 2021-02-12 10:22

I have a table which has a field `activated_at` timestamp NULL DEFAULT NULL, which means that it can contain a timestamp or it can be null and it\'s

5条回答
  •  一生所求
    2021-02-12 11:07

    If i understand right you can use andWhere

     ->andWhere(['not', ['activated_at' => null]])
    

    but andFilterWhere in execute where the related value is not null

    from doc http://www.yiiframework.com/doc-2.0/yii-db-query.html

    andFilterWhere() Adds an additional WHERE condition to the existing one but ignores empty operands.

提交回复
热议问题