使用cake php打印条件等于id数组的数据

时间:2017-10-03 11:05:26

标签: php cakephp-3.0

我正在尝试打印来自该查询的数据,其中bstockBooksTableResearchIds是相等的数组(1,2,3),但我收到的错误显示如下:

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

                ]) ;

enter image description here

2 个答案:

答案 0 :(得分:1)

您应该在条件中添加IN,以便您的代码

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

答案 1 :(得分:0)

试试这个:

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

                    )) ;

更改:IN子句应该在数组中。