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)    

 [2005-03-06 08:38 UTC] akorthaus at web dot de
Description: ------------ I tried to write an autoExecute() methode for ADOdb ( 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); } }


 [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 In case this was a 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.