zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Yii2查询语句使用不等于号

查询 语句 yii2 使用
2023-09-11 14:20:10 时间

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 yii\db\QueryInterface