pounard / goat-query

Goat SQL query builder built over a PHP to SQL and SQL to PHP type converter
GNU General Public License v2.0
2 stars 0 forks source link

Allow callables instead of all expressions #6

Closed pounard closed 3 years ago

pounard commented 5 years ago

Normalize expression processing, allow them to be callables, everywhere, examples:

$select->with('top_sales', function (SelectQuery $select) {
    // $select is a new SELECT query to be used for the WITH statement
    // ... write your own $select query
});

Or:

$select->condition(function (Where $where) {
    // ... do something with $where
});

Or:

$select->getWhere()->exists(function (SelectQuery $query) {
    // $select is a new SELECT query to be used for the WITH statement
    // ... write your own $select query
});

Or more generally, all expressions to be:

$select->expression(function (...$contextualParameters) {
    // ... return some string or Expression instance
});
pounard commented 3 years ago

Query builder has been subjected to a major overhaul, it's now much more flexible and accepts arbitrary expressions and callables pretty much everywhere it's possible. This is fixed.