One more time?

On Dec 12, 8:07 am, RhythmicDevil <[email protected]> wrote:
> Bump!
>
> On Dec 10, 1:54 pm, RhythmicDevil <[email protected]> wrote:
>
>
>
>
>
>
>
> > I have been going around and around with this this morning trying to
> > sort out the correct syntax for an $or containing multiple $regex
>
> > So in RockMongo I use this:
>
> > {
> > "$or" : [
> >         {"ingredient" : {"$regex" : /^aru/i}},
> >         {"ingredient" : {"$regex" : /^bro/i}},
> >         ]
>
> > }
>
> > It returns two items from my DB
>
> > However I cannot figure out the correct syntax to use to accomplish
> > the same thing using Cake's MongoDB datasource. The method below only
> > returns an item that matches on the last item in the $conditions
> > array.
>
> >     public function test()
> >     {
>
> >          //'Ingredient.ingredient'
> >         $conditions = array();
> >         $conditions[] = array('Ingredient.ingredient' =>
> > array('$regex' => new MongoRegex('/^arug/i')));
> >         $conditions[] = array('Ingredient.ingredient' =>
> > array('$regex' => new MongoRegex('/^bro/i')));
>
> >         $query = array(
> >             'limit' => 15,
> >             'order' => array(
> >                 'Ingredient.ingredient' => 'asc',
> >                 'Ingredient.type' => 'asc'),
> >             'conditions' => array('$or' => $conditions)
> >         );
>
> >         var_dump($query);
>
> >         $ingredients = $this->Ingredient->find('all', $query);
> >         var_dump($ingredients);
> >         exit();
> >     }
>
> > Any help would be appreciated.
>
> > Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to