简体   繁体   中英

$in doesn't work inside $or in MONGO CAKEPHP

Hi I have a query where $in is to be used inside $or because there are two set of conditions.

(

    [conditions] => Array
        (
            [$or] => Array
                (
                    [0] => Array
                        (
                            [id] => Array
                                (
                                    [$in] => Array
                                        (
                                            [0] => 53fc47ee6eb2361111ba4364
                                            [1] => 53fc48336eb2361311ba4360
                                            [2] => 53fc48716eb2361411ba4360
                                        )

                                 )

                         )

                )

       )

)

It is giving me an empty result but if skip $or and directly use id under conditions it will give me desired result. Following format is working fine. But as you know i need $or for second set of conditions.

(

    [conditions] => Array
        (
            [id] => Array
               (
                   [$in] => Array
                       (
                           [0] => 53fc47ee6eb2361111ba4364
                           [1] => 53fc48336eb2361311ba4360
                           [2] => 53fc48716eb2361411ba4360
                       )

                )

       )

)

Again, I need $or because I need to have two set of conditions inside or. I only displayed one here.

I am using ICHIKAWAY CAKEPHP MONGO Plugin.

Please help !!!

Use $in in ICHIKAWAY CAKEPHP MONGO Plugin:

$this->paginate = array('conditions' => array(
            'category' => array('$in'=>array('123', 'a', 'abc')))
        );

Above code will select all categories in array('123', 'a', 'abc')

I hope this will help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM