dstudio
(Nedim T)
May 16, 2016, 10:58pm
1
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.
dstudio
(Nedim T)
May 17, 2016, 1:39pm
2
dstudio:
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.
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]