Yii2查询语句使用不等于号

Yii2 Active Record查询条件使用不等于号,需要使用到

operator format: [operator, operand1, operand2, ...]

运算符格式: [运算符, 运算对象1, 运算对象2, ...]

演示代码:

$details = MovieShows::find()->where(['movie_id'=>$id])
           ->andWhere(['location_id'=>$loc_id])
           ->andWhere(['<>','cancel_date', $date])->all();

从演示的代码的最后一行代码,可以看到第一个元素是运算符号,第二个元素是数据表中的字段,第三个元素是值。

文章参考了:

  1. How to use not equal to inside a Yii2 query
  2. Interface yiidbQueryInterface
原文地址:https://www.cnblogs.com/fsong/p/5638594.html