How to use not equal to inside a Yii2 query

后端 未结 9 1782
無奈伤痛
無奈伤痛 2021-02-01 01:20

I want to use a yii2 query in which I want to check a not equal to condition. I tried like this but it didn\'t give the desired results. How do I do it?



        
9条回答
  •  误落风尘
    2021-02-01 02:01

    You can also try this:

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

    for Greater than

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

    for less than

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

    More check here

提交回复
热议问题