@@ -27,7 +27,10 @@ class Builder extends \Illuminate\Database\Query\Builder {
2727 '= ' , '< ' , '> ' , '<= ' , '>= ' , '<> ' , '!= ' ,
2828 'like ' , 'not like ' , 'between ' , 'ilike ' ,
2929 '& ' , '| ' , '^ ' , '<< ' , '>> ' ,
30- 'exists ' , 'type ' , 'mod ' , 'where ' , 'all ' , 'size ' , 'regex ' , 'elemmatch '
30+ 'rlike ' , 'regexp ' , 'not regexp ' ,
31+ 'exists ' , 'type ' , 'mod ' , 'where ' , 'all ' , 'size ' , 'regex ' , 'text ' , 'slice ' , 'elemmatch ' ,
32+ 'geowithin ' , 'geointersects ' , 'near ' , 'nearsphere ' , 'geometry ' ,
33+ 'maxdistance ' , 'center ' , 'centersphere ' , 'box ' , 'polygon ' , 'uniquedocs ' ,
3134 );
3235
3336 /**
@@ -90,7 +93,7 @@ public function getFresh($columns = array())
9093 $ wheres = $ this ->compileWheres ();
9194
9295 // Use MongoDB's aggregation framework when using grouping or aggregation functions.
93- if ($ this ->groups || $ this ->aggregate )
96+ if ($ this ->groups or $ this ->aggregate )
9497 {
9598 $ group = array ();
9699
@@ -652,7 +655,7 @@ protected function performUpdate($query, array $options = array())
652655 */
653656 public function convertKey ($ id )
654657 {
655- if (is_string ($ id ) && strlen ($ id ) === 24 && ctype_xdigit ($ id ))
658+ if (is_string ($ id ) and strlen ($ id ) === 24 and ctype_xdigit ($ id ))
656659 {
657660 return new MongoId ($ id );
658661 }
@@ -680,15 +683,26 @@ protected function compileWheres()
680683 {
681684 $ where ['operator ' ] = strtolower ($ where ['operator ' ]);
682685
683- // Fix elemMatch.
684- if ($ where ['operator ' ] == 'elemmatch ' )
686+ // Operator conversions
687+ $ convert = array (
688+ 'regexp ' => 'regex ' ,
689+ 'elemmatch ' => 'elemMatch ' ,
690+ 'geointersects ' => 'geoIntersects ' ,
691+ 'geowithin ' => 'geoWithin ' ,
692+ 'nearsphere ' => 'nearSphere ' ,
693+ 'maxdistance ' => 'maxDistance ' ,
694+ 'centersphere ' => 'centerSphere ' ,
695+ 'uniquedocs ' => 'uniqueDocs ' ,
696+ );
697+
698+ if (array_key_exists ($ where ['operator ' ], $ convert ))
685699 {
686- $ where ['operator ' ] = ' elemMatch ' ;
700+ $ where ['operator ' ] = $ convert [ $ where [ ' operator ' ]] ;
687701 }
688702 }
689703
690704 // Convert id's.
691- if (isset ($ where ['column ' ]) && $ where ['column ' ] == '_id ' )
705+ if (isset ($ where ['column ' ]) and $ where ['column ' ] == '_id ' )
692706 {
693707 // Multiple values.
694708 if (isset ($ where ['values ' ]))
@@ -707,7 +721,7 @@ protected function compileWheres()
707721 }
708722
709723 // Convert DateTime values to MongoDate.
710- if (isset ($ where ['value ' ]) && $ where ['value ' ] instanceof DateTime)
724+ if (isset ($ where ['value ' ]) and $ where ['value ' ] instanceof DateTime)
711725 {
712726 $ where ['value ' ] = new MongoDate ($ where ['value ' ]->getTimestamp ());
713727 }
0 commit comments