[turba] [patch] fix oracle clob support
    Matt Selsky 
    selsky at columbia.edu
       
    Fri Aug 13 01:26:53 PDT 2004
    
    
  
The attached patch fixes Oracle CLOB support in Turba v1.2.2.  Bind 
variables must be used in order to allow Oracle to take advantage of 
CLOBs and be able to fix more than 4K of data in CLOB fields.
This patch is not database specific.
See also http://bugs.horde.org/ticket/?id=443
-------------- next part --------------
--- /src/acis/cubmail/v2.5/src/horde/turba/lib/Driver/sql.php	2003-02-09 20:18:10.000000000 -0500
+++ /etc/httpd/htdocs/horde/turba/lib/Driver/sql.php	2004-08-13 04:14:20.687424000 -0400
@@ -197,13 +197,14 @@
         $values = array();
         foreach ($attributes as $field => $value) {
             $fields[] = $field;
-            $values[] = $this->db->quote($value);
+            $values[] = $value;
         }
 
         $query  = 'INSERT INTO ' . $this->table . ' (' . implode(', ', $fields) . ')';
-        $query .= ' VALUES (' . implode(', ', $values) . ')';
+        $query .= ' VALUES (' . str_repeat('?, ', count($values) - 1) . '?)';
 
-        $result = $this->db->query($query);
+        $sth = $this->db->prepare($query);
+        $result = $this->db->execute($sth,$values);
         return DB::isError($result) ? $result : true;
     }
 
@@ -228,15 +229,21 @@
         $where = $object_key . ' = ' . $this->db->quote($object_id);
         unset($attributes[$object_key]);
 
-        $set = array();
+        $fields = array();
+        foreach ($attributes as $field => $value) {
+            $fields[] = $field . ' = ?';
+        }
+
+        $values = array();
         foreach ($attributes as $field => $value) {
-            $set[] = $field . ' = ' . $this->db->quote($value);
+            $values[] = $value;
         }
 
-        $query  = 'UPDATE ' . $this->table . ' SET ' . implode(', ', $set) . ' ';
+        $query  = 'UPDATE ' . $this->table . ' SET ' . implode(', ', $fields) . ' ';
         $query .= 'WHERE ' . $where;
 
-        $result = $this->db->query($query);
+        $sth = $this->db->prepare($query);
+        $result = $this->db->execute($sth, $values);
 
         return (!DB::isError($result));
     }
    
    
More information about the turba
mailing list