Expressions with 'or'
Closed this issue · 3 comments
autowp commented
Not sure that is unexpected, but zf1 db works differently with 'or' in expressions
$select = new Sql\Select();
$select->where(['column1 is null or column1 = 2']);
$select->where(['column2 = 3']);
print $select->getSqlString(); exit;
prints
SELECT * WHERE column1 is null or column1 = 2 AND column2 = 3
expected by me
SELECT * WHERE (column1 is null or column1 = 2) AND (column2 = 3)
froschdesign commented
but zf1 db works differently with 'or' in expressions
ZF1 != ZF2/ZF3
Use the methods nest
and unnest
:
$select->where->nest() // bracket opened
->isNull('column1')
->or
->equalTo('column1', '2')
->unnest(); // bracket closed
->equalTo('column2', '3')
froschdesign commented
An example in the documentation is missing.
ezimuel commented
@froschdesign thanks, @xrmx fixed the documentation!