Answer the question
In order to leave comments, you need to log in
How to add condition in Where yii2?
There is a request
$news = self::find()->where(['status' => self::STATUS_ENABLE])->andWhere(['datePublished' => '2016-04-04'])->all();
Answer the question
In order to leave comments, you need to log in
Maybe so?
->andWhere('datePublished< :datePublished',[':datePublished' => '2016-04-04']);
Try the following example:
$news = self::find()
->where(['status' => self::STATUS_ENABLE])
->andWhere([ '<', 'datePublished', '2016-04-04'])->all();
Maybe so?
$news = self::find()
->where(['status' => self::STATUS_ENABLE, 'datePublished' => '<2016-04-04'])->all();
$news = self::find()
->where(['status' => self::STATUS_ENABLE'])->andWhere('datePublished < :datePublished',[':datePublished' => '2016-04-04'])->all();
$news = self::find()
->where(['status' => self::STATUS_ENABLE])
->andFilterWhere([ '<', 'datePublished', '2016-04-04'])->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question