Y
Y
Yaroslav Studenikin2020-09-01 19:46:51
MySQL
Yaroslav Studenikin, 2020-09-01 19:46:51

Double sort with Yii2 DB?

Hello! I ran into a seemingly simple problem, but I can not solve it.
I want to pull records from the table that have status -2 and 0.
How to build such a query on ActiveQuery?
Tried adding another Andwhere(['status' => '-2']). Returns an empty array.
Help me please.

$newGoods = Good::find()
            ->where(['>', 'good', self::SELECT_COUNT_GOODS_MIN])
            ->andWhere(['<=', 'good', self::SELECT_COUNT_GOODS_MAX])
            ->andWhere(['status' => '0'])
            ->limit(self::COUNT_GOODS_IN_ONE_CYCLE)
            ->asArray()
            ->all();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question