MangoDB: select where like

608 Views Asked by At

I'm just trying out the Kohana MongoDB ORM: MangoDB. I'm trying to figure out how to do a where like.

$query['city'] = $this->request->query('location');
$results = Mango::factory('salon')
    ->load(array(
        'limit' => null,
        'criteria' => $query
    ));

I want to change this to do a where like:

SELECT * FROM salon WHERE city LIKE '%London%'
1

There are 1 best solutions below

0
rakhim On BEST ANSWER

MongoDB supports regular expressions:

db.collection.find( { city: /*London*/i } );

See documentation here: http://docs.mongodb.org/manual/reference/operator/regex/