Question

i want to get multiple rows value base on multiple id value and i m getting id in array.

id output array

pr($currentSessionData['Category']);
Array
(
    [Category] => Array
        (
            [0] => 1
            [1] => 24
            [2] => 25
        )

)

Below code for getting rows value but not working

$this->YourModelName->find('all', array(
            'conditions' => array(
                        "YourModelName.id" => array($currentSessionData['Category'])
                )
));
Was it helpful?

Solution

dont use array() .eg array($currentSessionData['Category'])

Try this.

$cat_ids=array(0=>10,1=>51,2=>51,3=>6561,4=>1,5=>561);

$this->YourModelName->find('all', array(
            'conditions' => array(
                        "YourModelName.id" => cat_ids  /*dont use array() */
                )
));

i hope its helpful for you :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top