On Saturday 27 January 2007 7:43 am, Jochem Maas wrote: > Larry Garfield wrote: > > I have long since given up on raw insert/update/delete statements as the > > syntax is all kinds nasty. These days I just do this, which is even > > easier and more powerful: > > > > http://www.garfieldtech.com/blog/simplifying-sql > > a quick look at those funcs gives me the impression that they are woefully > inadequate for any level of complex realworld use. That's interesting, because I've been using variants of that for a year now with much success in a dozen projects. > query builders are alot more fiddly to get 'right' than one might imagine, > dealing with NULLs, booleans and dates for example (as Satyam pointed out) > can be a right PITA. I actually almost never use native date types in the SQL database. I just store unix timestamps and do the math in PHP. Dates are completely unportable anyway. I also tend to use ints for booleans, too, although beefing up the switch statements in the code to handle native booleans should be trivial. > perfect automated CRUD (it's an acronym!) is kind a holy grail - and > that is, I think, the driving force behind most attempts to crteate query > builders. Orthogonal persistence is, yes. The goal here was simply to make dealing with arbitrary insert and update statements easier, which in practice I've found to be a huge success. Full arbitrary CRUD and orthogonal persistence is much harder. That's why there's a dozen ORMs out there, all of which have some major flaw. :-) > also I don't really agree with the sentiment that SQL syntax is nasty, > personally I find it, mostly, very easy to read and powerful ... but as > this thread shows there is no accounting for taste! :-) What bugs me most about SQL syntax is INSERT vs. UPDATE. I don't know the underlying implementation details of the engine, but from the level I work at (sending SQL to a database from a web app) I see no legitimate reason why those two very-similar statements should have ridiculously different syntax. -- Larry Garfield AIM: LOLG42 larry@xxxxxxxxxxxxxxxx ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php