gpt4 book ai didi

cakephp-3.0 - Cakephp 3 查询或条件

转载 作者:行者123 更新时间:2023-12-04 17:32:38 24 4
gpt4 key购买 nike

伙计们,我如何在以下 Where 语句中应用 OR 条件?

$this->IbCommisions->find()->matching(
'Users.Accounts',function ($q) {
return $q->where(['IbCommisions.ib_id' => $this->userid, 'Users.country_id' => $this->request->data['country']]);
}

变得像
(['IbCommisions.ib_id' => $this->userid OR 'Users.country_id' => $this->request->data['country']])

最佳答案

return $q->where(['OR' => [
'IbCommisions.ib_id' => $this->userid,
'Users.country_id' => $this->request->data['country']
]]);

或者
return $q->where(['IbCommisions.ib_id' => $this->userid])
->orWhere(['Users.country_id' => $this->request->data['country']]);

http://book.cakephp.org/3.0/en/orm/query-builder.html#advanced-conditions

关于cakephp-3.0 - Cakephp 3 查询或条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38635811/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com