[nycphp-talk] ORM vs SQL: the ultimate showdown
Paul Houle
paul at devonianfarm.com
Sat Sep 15 13:14:11 EDT 2007
Ben Sgro (ProjectSkyLine) wrote:
>
>
> Why not just do:
>
> SET ...
> first_name = $firstname,
> last_name = $lastname, ...
>
> Which is *basically* the same as what your saying ORM is useful for in
> this case...
That's a very nice syntax. It's also mysql-specific. I love
mysql, and it may be very sensible to build a mysql app that takes
advantage of great features like this, but many of us need to write
apps for postgreSQL, Oracle, MS SQL and other databases that don't
support this (superior) syntax.
Another advantage of an ORM system is that it can use database
metadata to validate data much better than addslashes() can. For
instance, some databases will let you get away with
UPDATE TABLE SET an_integer_field='55';
Other databases (for instance, MS Access) won't, and you need to write
UPDATE TABLE SET an_integer_field=55;
If '55' comes from the outside, you'll want to validate that it's
an integer. Do you want to write that code by hand every time? Or
would you like your ORM system to automatically detect the type based on
database metadata, and give you an intelligible error message like :
"776krashyourdatabase is not an integer" rather than "Invalid SQL Syntax
(Code 7719290)."
I find that I spent entirely too much time dealing with error
conditions in my code, and welcome anything that makes that work easier.
More information about the talk
mailing list