dg / dibi

Dibi - smart database abstraction layer
https://dibiphp.com
Other
487 stars 135 forks source link

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

Open VladaHejda opened 8 years ago

VladaHejda commented 8 years ago

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'))

dg commented 8 years ago

Can you try to fix it?

h4kuna commented 6 years ago

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.