suggestions for DB class autoExecute() method

From: Date: Mon, 19 Jan 2004 03:34:51 +0000
Subject: suggestions for DB class autoExecute() method
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25144@lists.php.net to get a copy of this message
This is my first post on the PHP/Pear mailing list, and I'm still not sure if this is the sort of thing that qualifies as worthy of the dev list, but it seemed too development-oriented for the general list. If I am wrong, I apologize. Anyhoo, I was considering moving from a relatively simple class I wrote to the Pear DB class due to its wide array features and excellent portability, but there are a few options that I've grown accustomed to in my own class that appear to be missing from the pear one, all of which involve the automatic query inserts/updates. *I would like to apologize in advance if these features exist and I simply overlooked them in the docs or the code.* 1. There doesn't appear to be any way to have "as is" values in auto insert /auto update statements, as buildManipSQL uses '?' as the placeholder for DB_AUTOQUERY_INSERT and DB_AUTOQUERY_UPDATE modes. Is there a way to do use '!' instead? There doesn't appear to be, and again I apologize if I haven't RTFM'd enough. In the class I've been using, I included a simple method called dont_quote_field. Looking at the Pear class, it seems that there would have to be something that would allow the user to set a particular key in the key=>value hash to DB_PARAM_MISC 2. It may be advantageous to allow users to pass a $where string that includes the WHERE keyword, just for readability in their own code. For instance, in buildManipSQL: if ($where) { $sql .= " WHERE $where"; } might use something like this before it: $where = preg_replace('/^\s*WHERE\s/i', '', $where); just so a coder could pass the parameter 'WHERE foo=bar', rather than the more ambiguous 'foo=bar' 3. It might be easier for the user if you were add a simple method, perhaps autoUpdate(), that's just an alias to autoExecute with the $mode set to DB_AUTOQUERY_UPDATE by default. That way $mode won't have to be explicitly set in the function call. 4. In my own class, I was very determined not to allow update queries to execute without a where statement, so unless either SQL_DB_AUTO_UPDATE_REQUIRES_WHERE was defined to zero, or $db_object->auto_update_requires_where was set to false, the query will not execute and will raise an error. I noticed in your comments that you mention this possible slip up, but it may be advantageous to give the user (read: me :) a similar failsafe mechanism so that they don't ruin their entire table. I think those are the only issues I've had. Please know that I'm not trying to find fault, I think the class is excellent and leaps and bounds above what I'm using, I just wanted to see what others thought of those suggestions. I'm very excited about delving into Pear, and hope to possibly contribute sometime in the future. -Jim Keller p.s. If you'd like to see the DB class I've been using and talking about in this email, it's located at http://jim.centerfuse.net/SQL_DB/SQL_DB.class.phps

« previous php.pear.dev (#25144) next »