laminas / laminas-db

Database abstraction layer, SQL abstraction, result set abstraction, and RowDataGateway and TableDataGateway implementations
https://docs.laminas.dev/laminas-db/
BSD 3-Clause "New" or "Revised" License
122 stars 68 forks source link

Make an 'or' and 'and' method in Laminas\Db\Sql\Predicate\Predicate? #246

Open WillyBaldy opened 2 years ago

WillyBaldy commented 2 years ago

Feature Request

I'm not sure if this is really a feature request, but currently when building a query using Laminas\Db\Select we can do something like this:

$select->where->nest() // bracket opened
    ->isNull('column1')
    ->or
    ->equalTo('column1', '2')
    ->unnest();  // bracket closed
    ->equalTo('column2', '3');

There is no method we can call for "or", and PHPStorm doesn't like this by default. I don't like it either, I think in 2022 we're passed the era of magic methods. It would be amazing if methods "or" and "and" could be called instead, similar to how we can call "nest" and "unnest" methods.

Any thoughts?