Commit dc3ada65 by Klimov Paul

Mongo query "IN" condition shortcut syntax added.

parent a0384498
...@@ -242,7 +242,13 @@ class Collection extends Object ...@@ -242,7 +242,13 @@ class Collection extends Object
if (is_numeric($key)) { if (is_numeric($key)) {
$result[] = $actualValue; $result[] = $actualValue;
} else { } else {
$result[$this->normalizeConditionKeyword($key)] = $actualValue; $key = $this->normalizeConditionKeyword($key);
if (strncmp('$', $key, 1) !== 0 && array_key_exists(0, $actualValue)) {
// shortcut for IN condition
$result[$key]['$in'] = $actualValue;
} else {
$result[$key] = $actualValue;
}
} }
} }
return $result; return $result;
......
...@@ -75,9 +75,7 @@ class QueryRunTest extends MongoTestCase ...@@ -75,9 +75,7 @@ class QueryRunTest extends MongoTestCase
$query = new Query; $query = new Query;
$rows = $query->from('customer') $rows = $query->from('customer')
->where([ ->where([
'name' => [ 'name' => ['name1', 'name5']
'in' => ['name1', 'name5']
]
]) ])
->all($connection); ->all($connection);
$this->assertEquals(2, count($rows)); $this->assertEquals(2, count($rows));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment