Cakephp 3 Request OR Condition

Guys, how can I apply the OR condition in the following Where statement?

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

To become something like

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

or alternatively

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

+5
source

Source: https://habr.com/ru/post/1649400/


All Articles