dibi icon indicating copy to clipboard operation
dibi copied to clipboard

Allow $query->from()->select()

Open VladaHejda opened this issue 9 years ago • 2 comments
trafficstars

It would be nice, if I can start query with FROM part and then define columns to select.

When I call $dibi->command()->from('foo')->select('bar') Dibi will produce query FROM foo SELECT bar which is obviously syntax error. If there is a requirement to know the type of query before call of from(), it would work like $dibi->select()->from('foo')->select('bar') with no column definition at first select() call (but now it reproduces query SELECT , bar FROM foo - again error).

This change let make more comfortable APIs in some cases.

(the only way to do this now is to call something like $dibi->select('*')->removeClause('SELECT'))

VladaHejda avatar Jan 12 '16 12:01 VladaHejda

Can you try to fix it?

dg avatar Jul 20 '16 13:07 dg

Yeasterday, I tried fix it.

  1. table()->select() is easy fix.

  2. Do you want it? I expect api must support table()->insert(), table()->update() and table()->delete() this is little more complex, because class Connection has logic how works with arguments. This update change api update('table', $data) vs ->table('table')->update($data) etc.

h4kuna avatar Feb 23 '18 08:02 h4kuna