Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Request #3721 change buildManipSQL() to use PHP-functions
Submitted: 2005-03-06 08:38 UTC
From: akorthaus at web dot de Assigned:
Status: Closed Package: MDB2
PHP Version: 5.0.3 OS: Linux 2.4.28 (Gentoo)
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 23 + 12 = ?

 
 [2005-03-06 08:38 UTC] akorthaus at web dot de
Description: ------------ I tried to write an autoExecute() methode for ADOdb (http://phplens.com/lens/lensforum/msgs.php?id=11643). Now it is implemented there, but not 1:1 my version (but based on this code), which I wrote on base of PEAR::DB/MDB/2, perhaps it is useful for you, I reduced the changes to buildManipSQL() from Extended.php. Difference is that I do not use php-loops (foreach), but I use php-functions as implode() and str_repeat() instead (should be faster). Reproduce code: --------------- function buildManipSQL($table, $table_fields, $mode, $where = false) { $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; if (count($table_fields) == 0) { $db->raiseError(MDB2_ERROR_NEED_MORE_DATA); } switch ($mode) { case MDB2_AUTOQUERY_INSERT: $cols = implode(',', array_keys($table_fields)); $values = '?'.str_repeat(',?', count($table_fields)-1); return 'INSERT INTO '.$table.' ('.$cols.') VALUES ('.$values.')'; break; case MDB2_AUTOQUERY_UPDATE: $set = implode('= ?,', array_keys($table_fields)).'= ?'; $sql = 'UPDATE '.$table.' SET '.$set; if ($where !== false) $sql .= ' WHERE '.$where; return $sql; break; default: $db->raiseError(MDB2_ERROR_SYNTAX); } }

Comments

 [2005-03-06 16:15 UTC] smith at backendmedia dot com
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.