如何在 CAKEPHP 3.x 中获取 table 记录中的组合查询参数

How to do combination query parameter in fetching table records in CAKEPHP 3.x

在 cakephp 2 上,我有一个在控制器中 'collect' 参数的方法,例如,在视图中,我有组合框 A、组合框 B、输入 'keyword' 和控制器。然后我在 CONtroller 上收集该数据以创建条件过滤器。

然后我可以在我的条件查询中使用它,例如:'conditions'=>$condition。然后不知何故在CakePHP 3中,数组变成了[],所以我不能再使用这个方法了。

如何在 CakePHP 3 中模仿该方法?还是有其他方法来收集条件?

我试过和array一样的方法,但是不行。我还不能在网上找到它。这里是我之前做的示例集合

$conditions = array();
$conditions['StoreProduct.stok >']=0;
$conditions['StoreProduct.deleted']=0;

我建议您像这样使用查询生成器:

$query = $articles
->find()
->select(['id', 'name'])
->where(['condition1 >' => 0, 'condition2' => 0])
->order(['created' => 'DESC']);

更多信息:https://book.cakephp.org/3.0/en/orm/query-builder.html#selecting-data