Yii2 MongoDB Query Issue

I am trying to generate a query like this:


WHERE (total_orders > 20) AND ((clv = 10) OR (total_orders = 200))

So I have decided to use \yii\mongodb\Query class and the following code:


$query = new \yii\mongodb\Query;

$query->from('email');

$where = ['and', 'total_orders > 20', ['or', 'clv = 10', 'total_orders = 200']];

What I got is only an exception:


Invalid Parameter – yii\base\InvalidParamException

 

Condition should be an array.

When I change an instance of $query to \yii\db\Query, there is an error that my table within mySQL database does not exist, which is logical, but it doesn’t return an exception like with MongoDB, so there is something wrong with \yii\mongodb\Query class.

Interesting. This is my second question in the last two weeks and no answer.

http://www.yiiframework.com/forum/index.php/topic/70811-oauth2-how-to-change-access-type/page__p__299308#entry299308

Hi,

I think you have problem with building query





$condition = [

    [

        'OR',

        ['AND', ['first_name' => 'John'], ['last_name' => 'Smith']],

        ['status' => [1, 2, 3]]

    ],

];

you are missing array symbol [size=2] [/size][size=2][] [/size][size=2]inside your query[/size]