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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!