如何在 Yii2 查询中使用不等于

2024-02-14

我想用一个yii2我想在其中检查不等于条件的查询。

我这样尝试过,但没有给出想要的结果。我该怎么做?

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

在这种情况下你需要使用运算符格式: [operator, operand1, operand2, ...]。所以你的代码应该是这样的:

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

More http://www.yiiframework.com/doc-2.0/yii-db-queryinterface.html#where%28%29-detail关于使用 where 方法和运算符格式

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Yii2 查询中使用不等于 的相关文章

随机推荐