phpLens
 home  products examples manual  faq support forum  contact news  login store

Forums: phplens   adodb
Forums:   ADOdb Help & Dev:   Replies 
New ReplySearch
Topic: Patch: Fix for ADODB_Active_Record::doquote()
author: Jonathan Hohle   created: 13-01-2009 04:39:59 PM
ADODB_Active_Record::doquote() does not properly quote a string that has single quotes within it. This patch ensures that a string with single quotes is quoted properly while retaining the functionality of not quoting strings that start and end with single quotes.

(Line number may be off from other patches)

Example where current version fails:

class Foo extends ADOdb_Active_Record {}
$foo = new Foo();
$foo->Name = "this is 'my name'";
$foo->Replace();

===================================================================
--- vendor/adodb/adodb-active-record.inc.php (revision 5025)
+++ vendor/adodb/adodb-active-record.inc.php (working copy)
@@ -627,8 +627,13 @@
case 'C':
case 'X':
if (is_null($val)) return 'null';
+
+ $val_len = strlen($val);
+ if (!($val_len > 1 &&
+ $val{0} === "'" &&
+ $val{$val_len-1} === "'" &&
+ substr_count($val, "'") === 2)) {

- if (strncmp($val,"'",1) != 0 && substr($val,strlen($val)-1,1) != "'") {
return $db->qstr($val);
break;
}
Topic: Re:Patch: Fix for ADODB_Active_Record::doquote()
author: John Lim   created: 15-01-2009 11:05:15 AM
Thanks for the fixes.

I will be adding all of them, including the readcache and setdatabaseadapter fix.
Topic: Re:Patch: Fix for ADODB_Active_Record::doquote()
author: Jonathan Hohle   created: 15-01-2009 11:29:56 AM
Good to hear! Keep up the great work!
Page 1
New ReplySearch

View Source

email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800