|
|
@ -651,7 +651,7 @@ class Collection extends Object |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Converts user friendly condition keyword into actual Mongo condition keyword. |
|
|
|
* Converts "\yii\db\*" quick condition keyword into actual Mongo condition keyword. |
|
|
|
* @param string $key raw condition key. |
|
|
|
* @param string $key raw condition key. |
|
|
|
* @return string actual key. |
|
|
|
* @return string actual key. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -659,25 +659,8 @@ class Collection extends Object |
|
|
|
{ |
|
|
|
{ |
|
|
|
static $map = [ |
|
|
|
static $map = [ |
|
|
|
'OR' => '$or', |
|
|
|
'OR' => '$or', |
|
|
|
'>' => '$gt', |
|
|
|
|
|
|
|
'>=' => '$gte', |
|
|
|
|
|
|
|
'<' => '$lt', |
|
|
|
|
|
|
|
'<=' => '$lte', |
|
|
|
|
|
|
|
'!=' => '$ne', |
|
|
|
|
|
|
|
'<>' => '$ne', |
|
|
|
|
|
|
|
'IN' => '$in', |
|
|
|
'IN' => '$in', |
|
|
|
'NOT IN' => '$nin', |
|
|
|
'NOT IN' => '$nin', |
|
|
|
'ALL' => '$all', |
|
|
|
|
|
|
|
'SIZE' => '$size', |
|
|
|
|
|
|
|
'TYPE' => '$type', |
|
|
|
|
|
|
|
'EXISTS' => '$exists', |
|
|
|
|
|
|
|
'NOTEXISTS' => '$exists', |
|
|
|
|
|
|
|
'ELEMMATCH' => '$elemMatch', |
|
|
|
|
|
|
|
'MOD' => '$mod', |
|
|
|
|
|
|
|
'%' => '$mod', |
|
|
|
|
|
|
|
'=' => '$$eq', |
|
|
|
|
|
|
|
'==' => '$$eq', |
|
|
|
|
|
|
|
'WHERE' => '$where' |
|
|
|
|
|
|
|
]; |
|
|
|
]; |
|
|
|
$matchKey = strtoupper($key); |
|
|
|
$matchKey = strtoupper($key); |
|
|
|
if (array_key_exists($matchKey, $map)) { |
|
|
|
if (array_key_exists($matchKey, $map)) { |
|
|
@ -759,7 +742,6 @@ class Collection extends Object |
|
|
|
{ |
|
|
|
{ |
|
|
|
$result = []; |
|
|
|
$result = []; |
|
|
|
foreach ($condition as $name => $value) { |
|
|
|
foreach ($condition as $name => $value) { |
|
|
|
$name = $this->normalizeConditionKeyword($name); |
|
|
|
|
|
|
|
if (strncmp('$', $name, 1) === 0) { |
|
|
|
if (strncmp('$', $name, 1) === 0) { |
|
|
|
// Native Mongo condition: |
|
|
|
// Native Mongo condition: |
|
|
|
$result[$name] = $value; |
|
|
|
$result[$name] = $value; |
|
|
@ -769,12 +751,8 @@ class Collection extends Object |
|
|
|
// Quick IN condition: |
|
|
|
// Quick IN condition: |
|
|
|
$result = array_merge($result, $this->buildInCondition('IN', [$name, $value])); |
|
|
|
$result = array_merge($result, $this->buildInCondition('IN', [$name, $value])); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Normalize possible verbose condition: |
|
|
|
// Mongo complex condition: |
|
|
|
$actualValue = []; |
|
|
|
$result[$name] = $value; |
|
|
|
foreach ($value as $k => $v) { |
|
|
|
|
|
|
|
$actualValue[$this->normalizeConditionKeyword($k)] = $v; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$result[$name] = $actualValue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Direct match: |
|
|
|
// Direct match: |
|
|
|