0

I'm trying to print the data from that query where the bstockBooksTableResearchIds is equal array(1,2,3) , but i'm getting error showing in bellow :

$bstockBooksTableResearches = $this->BstockIn->BstockResearchs->find('list', [
            'conditions' => ['BstockResearchs.id' => $bstockBooksTableResearchIds],

                ]) ;

enter image description here

2
  • That's not an error, that's the dump of a query object, as the (help) key contents indicate. Commented Oct 3, 2017 at 11:17
  • 2
    Possible duplicate of How to create a `IN` clause in CakePHP query? Commented Oct 3, 2017 at 11:17

2 Answers 2

1

you should add IN in your conditions so your code will be

$bstockBooksTableResearches = $this->BstockIn->BstockResearchs->find('list', [
            'conditions' => [
                'BstockResearchs.id IN' => $bstockBooksTableResearchIds
                ]
            ]) ;
Sign up to request clarification or add additional context in comments.

Comments

0

try this:

 $bstockBooksTableResearches = $this->BstockIn->BstockResearchs->find('list', array(
                'conditions' =>array (
    'BstockResearchs.id' => $bstockBooksTableResearchIds),

                    )) ;

changes: IN clause should be in array.

3 Comments

square braces are not allowed where it was said ?? @Sucharitha
@tarikul05 : In my case for direct values square braces are working but in variables it raised error. so i thought it may not work.
it's may be your php version problem, PHP doc says As of PHP 5.4 you can also use the short array syntax, which replaces array() with []. so it allow for all. You can't say not allowed.

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.