Cake\Database\Query::orWhere PHP Method

orWhere() public method

It is important to notice that when calling this function, any previous set of conditions defined for this query will be treated as a single argument for the OR operator. This function will not only operate the most recently defined condition, but all the conditions as a whole. When using an array for defining conditions, creating constraints form each array entry will use the same logic as with the where() function. This means that each array entry will be joined to the other using the OR operator, unless you nest the conditions in the array using other operator. ### Examples: $query->where(['title' => 'Hello World')->orWhere(['title' => 'Foo']); Will produce: WHERE title = 'Hello World' OR title = 'Foo' $query ->where(['OR' => ['published' => false, 'published is NULL']]) ->orWhere(['author_id' => 1, 'comments_count >' => 10]) Produces: WHERE (published = 0 OR published IS NULL) OR (author_id = 1 AND comments_count > 10) $query ->where(['title' => 'Foo']) ->orWhere(function ($exp, $query) { return $exp ->add(['author_id' => 1]) ->or_(['author_id' => 2]); }); Generates the following conditions: WHERE (title = 'Foo') OR (author_id = 1 OR author_id = 2)
See also: Cake\Database\Query::where()
See also: Cake\Database\Type
public orWhere ( string | array | Cake\Database\ExpressionInterface | callable $conditions, array $types = [] )
$conditions string | array | Cake\Database\ExpressionInterface | callable The conditions to add with OR.
$types array associative array of type names used to bind values to query
    public function orWhere($conditions, $types = [])
    {
        $this->_conjugate('where', $conditions, 'OR', $types);
        return $this;
    }