CTEs
mathroc opened this issue · 1 comments
mathroc commented
Hi,
now that mysql will support WITH queries too, is there plan to add support for Common Table Expressions ?
maybe something along those lines :
$select = $query_factory->newSelect();
$cte = $query_factory->newSelect();
$cte->cols('zim')->from('table2');
$select->with('cte1', $cte);
$select->cols(array('foo', 'bar AS barbar'))
->from('table1')
->from('cte1')
->where('cte1.zim = 99');
pmjones commented
This is an excellent idea. It may mess up Atlas.Orm, which uses with()
to eager-load relationships -- but since Atlas is alpha, it can change to use eager()
or something like that instead of the WITH keyword.
@mathroc send along a PR as soon as you can, for the databases that support WITH, and I'll review!