]> git.mjollnir.org Git - moodle.git/commitdiff
Moving emulate_bound_params() from adodb drivers to adodb_moodle_database. MDL-14984
authorstronk7 <stronk7>
Sun, 25 May 2008 17:14:21 +0000 (17:14 +0000)
committerstronk7 <stronk7>
Sun, 25 May 2008 17:14:21 +0000 (17:14 +0000)
lib/dml/adodb_moodle_database.php
lib/dml/mssql_adodb_moodle_database.php
lib/dml/oci8po_adodb_moodle_database.php
lib/dml/postgres7_adodb_moodle_database.php

index 76548fa27082558f7db34d71b7a93f3cccfdf8cd..ff2b5532c36f71c512a27e8b76e435502eda0e42 100644 (file)
@@ -495,4 +495,29 @@ abstract class adodb_moodle_database extends moodle_database {
         return true;
     }
 
+    /**
+     * Very ugly hack which emulates bound parameters in mssql queries
+     * where params not supported (UpdateBlob) :-(
+     */
+    protected function emulate_bound_params($sql, array $params=null) {
+        if (empty($params)) {
+            return $sql;
+        }
+        /// ok, we have verified sql statement with ? and correct number of params
+        $return = strtok($sql, '?');
+        foreach ($params as $param) {
+            if (is_bool($param)) {
+                $return .= (int)$param;
+            } else if (is_null($param)) {
+                $return .= 'NULL';
+            } else if (is_numeric($param)) {
+                $return .= $param;
+            } else {
+                $param = $this->db->qstr($param);
+                $return .= "$param";
+            }
+            $return .= strtok('?');
+        }
+        return $return;
+    }
 }
index b9055c8523d1766c966af4cde98e2b458c04b042..4ee0080885c95443efb9e83fd72fb66651ff3af1 100644 (file)
@@ -297,31 +297,4 @@ class mssql_adodb_moodle_database extends adodb_moodle_database {
 
         return ($returnid ? $id : true);
     }
-
-    /**
-     * Very ugly hack which emulates bound parameters in mssql queries
-     * where params not supported (UpdateBlob) :-(
-     */
-    private function emulate_bound_params($sql, array $params=null) {
-        if (empty($params)) {
-            return $sql;
-        }
-        // ok, we have verified sql statement with ? and correct number of params
-        $return = strtok($sql, '?');
-        foreach ($params as $param) {
-            if (is_bool($param)) {
-                $return .= (int)$param;
-            } else if (is_null($param)) {
-                $return .= 'NULL';
-            } else if (is_numeric($param)) {
-                $return .= $param;
-            } else {
-                $param = $this->db->qstr($param);
-                $return .= "$param";
-            }
-            $return .= strtok('?');
-        }
-        return $return;
-    }
-
 }
index 06f9f75268dbd229ae0318ba59e3a96fefb2e9cb..e2a9c0aa514b9c1b3913595e9f479139ab03ff14 100644 (file)
@@ -532,32 +532,6 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database {
         return true;
     }
 
-     /**
-      * Very ugly hack which emulates bound parameters in mssql queries
-      * where params not supported (UpdateBlob) :-(
-      */
-     private function emulate_bound_params($sql, array $params=null) {
-         if (empty($params)) {
-             return $sql;
-         }
-         // ok, we have verified sql statement with ? and correct number of params
-         $return = strtok($sql, '?');
-         foreach ($params as $param) {
-             if (is_bool($param)) {
-                 $return .= (int)$param;
-             } else if (is_null($param)) {
-                 $return .= 'NULL';
-             } else if (is_numeric($param)) {
-                 $return .= $param;
-             } else {
-                 $param = $this->db->qstr($param);
-                 $return .= "$param";
-             }
-             $return .= strtok('?');
-         }
-         return $return;
-     }
-
     /**
      * This function is used to convert all the Oracle 1-space defaults to the empty string
      * like a really DIRTY HACK to allow it to work better until all those NOT NULL DEFAULT ''
index 92d544c157b726087345792d28b658c1d8d9e9b5..ccabab6d07c5de06c76a56ec2b955716e319c4de 100644 (file)
@@ -424,30 +424,4 @@ class postgres7_adodb_moodle_database extends adodb_moodle_database {
     public function sql_cast_char2int($fieldname, $text=false) {
         return ' CAST(' . $fieldname . ' AS INT) ';
     }
-
-    /**
-     * Very ugly hack which emulates bound parameters in pg queries
-     * where params not supported :-(
-     */
-    private function emulate_bound_params($sql, array $params=null) {
-        if (empty($params)) {
-            return $sql;
-        }
-        // ok, we have verified sql statement with ? and correct number of params
-        $return = strtok($sql, '?');
-        foreach ($params as $param) {
-            if (is_bool($param)) {
-                $return .= (int)$param;
-            } else if (is_null($param)) {
-                $return .= 'NULL';
-            } else if (is_numeric($param)) {
-                $return .= $param;
-            } else {
-                $param = $this->db->qstr($param);
-                $return .= "$param";
-            }
-            $return .= strtok('?');
-        }
-        return $return;
-    }
 }