0

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'])
                )
));
1
  • your code is pretty much correct.You need to check what query is generated by your find query. Commented Jan 31, 2014 at 10:24

1 Answer 1

3

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 :)

Sign up to request clarification or add additional context in comments.

2 Comments

yes u r right, could you tell me how can i remove category index in cakephp
$ar['Category']= array(0=>12,1=>13452,2=>1452,3=>12544); if(!empty($ar['Category'])) { foreach ($ar['Category'] as $k=>$v) { $arr[]=$v; } } pr($arr);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.