如何在CakePHP查询中创建`IN`子句? [英] How to create a `IN` clause in CakePHP query?
本文介绍了如何在CakePHP查询中创建`IN`子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在新的CakePHP中的where子句中使用它?我在尝试:
How do you make it where in clause in new CakePHP? I'm trying:
$restaurants->find()->where(['id' => $r_ids])->all();
其中 $ r_ids
推荐答案
对于CakePHP 3.x,现在需要指明数据类型,或明确使用 IN
关键字。
With CakePHP 3.x it's now necessary to either indicate the data type, or explicitly make use of the IN
keyword.
http://book.cakephp.org/3.0/en/orm/query-builder。 html#automated-create-in-clauses
http://book.cakephp.org/3.0/en/orm/query-builder.html#automatically-creating-in-clauses
$query = $articles->find()
->where(['id' => $ids], ['id' => 'integer[]']);
$query = $articles->find()
->where(['id IN' => $ids]);
这篇关于如何在CakePHP查询中创建`IN`子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文