I've been using the PEAR MDB2 package as database abstraction for my application. I am pretty happy with it, and chose it particularly because of the automatic table creation and manipulation from XML schema.
For all queries I've needed so far in my app, I've used autoPrepare() or autoExecute(). I get the field names and types from the XML files mentioned above - they are parsed on installation of the app and a hash of the field names, sizes, types etc. is stored for future use. So, for example, I can make a call to my db interface like this:
Code: Select all
$db->insert('posts', array($post_id, $uid, $subject, $message));My issue is that I now need to build more complex SQL statements. The first one I've come across is something like the following:
Code: Select all
UPDATE forums SET forum_posts = forum_posts + 1Sure, I can do this using prepare(), but is there any way to do it with autoPrepare()?The values passed in $data must be literals. Do not submit SQL functions (for example CURDATE()). SQL functions that should be performed at execution time need to be put in the prepared statement. Similarly, identifiers (i.e. table names and column names) can not be used because the names get validated during the prepare phase.
Thanks for any help.