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

Bug #5195 DB Wrapper adds double quotes
Submitted: 2005-08-24 10:21 UTC
From: o dot persson at gmail dot com Assigned: lsmith
Status: Closed Package: MDB2
PHP Version: 5.0.4 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2005-08-24 10:21 UTC] o dot persson at gmail dot com
Description: ------------ Not 100% sure that this is a bug, but it's causing problems for me. Using the DB wrapper with the Log-package gives me problem. This will need a small patch applied to Log/sql.php. Otherwise, the Log package will require the DB.php which contains a DB class as MDB2/Wrapper/peardb.php does. Below is also the propsed patch for peardb.php. I don't know if this is only a behaviour of the MySQL driver. Test script: --------------- require_once('Log.php'); require_once('MDB2.php'); MDB2::loadFile('Wrapper/peardb'); $dsn = 'mysql://user:pass@host/log-db'; $conf = array('dsn' => $dsn, 'sequence' => 'log_seq'); $logger = &Log::singleton('sql', 'log', 'ident', $conf); $logger->log('test'); Index: Log/sql.php =================================================================== --- Log/sql.php (revision 20) +++ Log/sql.php (working copy) @@ -8,7 +8,8 @@ */ /** PEAR's DB package */ -require_once 'DB.php'; +if (!class_exists('DB')) + require_once 'DB.php'; Index: MDB2/Wrapper/peardb.php =================================================================== --- MDB2/Wrapper/peardb.php (revision 23) +++ MDB2/Wrapper/peardb.php (working copy) @@ -363,7 +363,7 @@ if (is_null($string)) { return 'NULL'; } - return "'".$this->db_object->quote($string)."'"; + return $this->db_object->quote($string); } function escapeSimple($str) Expected result: ---------------- Data insterted into table log. Actual result: -------------- Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ident'', 3, ''MDB2 Error: syntax error'')' at line 1 Generated query: insert into log (id, logtime, ident, priority, message)values(189, CURRENT_TIMESTAMP, ''ident'', 3, ''MDB2 Error: syntax error'')

Comments

 [2005-08-24 10:27 UTC] lsmith
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I fixed the bug in MDB2. As for the necessary changes in Log its going to be tricky. The only feasible solution is for you to place a dummy DB.php file there.