How to use not equal to inside a Yii2 query

后端 未结 9 1663
無奈伤痛
無奈伤痛 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 01:59

    Maybe this one help...:)

    $query->andFilterWhere([ 'or',
                               ['<=', 'affidavit_cont', 0],
                               ['=', 'affidavit_cont1', 0],
                               ['>', 'affidavit_cont2', 0],
                               ['!=', 'affidavit_cont3', $this->affidavit3],
                               ['in', 'attempt_count', $this->attempted],
    
                          ]);
    
    $query->andFilterWhere(['like', 'job_invoice.paid_status', '',]);
    
    $query->andFilterWhere(['in', 'status_id', $this->status_id]);
    
    $query->andFilterWhere(['between', 'last_attempt',
        strtotime(Utility::convertDate2Db($this->from_date)),
        strtotime(Utility::convertDate2Db($this->to_date))
        ]);
    
    0 讨论(0)
  • 2021-02-01 01:59
            <?= $form->field($model, 'first_name')->dropDownList(
            arrayhelper::map(user::find()
                                    ->where([ 'not in ' ,'first_name', patient::find() ->select([ 'patient_name' ]) ->asArray()  ])
            ->all(),'id','first_name')
    

    Maybe it help you for whom need to use subquery .

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题