]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17880 fixed removing of leading 0 from strings when emulating bounds in DML
authorskodak <skodak>
Tue, 13 Jan 2009 13:12:59 +0000 (13:12 +0000)
committerskodak <skodak>
Tue, 13 Jan 2009 13:12:59 +0000 (13:12 +0000)
lib/dml/adodb_moodle_database.php
lib/dml/mysqli_native_moodle_database.php

index 6ea73e3cd013a48017ca1758b9b8a57e7099e5ea..703ee48a2183c77d9667dd4bac0fc6c813144273 100644 (file)
@@ -525,7 +525,9 @@ abstract class adodb_moodle_database extends moodle_database {
                 $return .= (int)$param;
             } else if (is_null($param)) {
                 $return .= 'NULL';
-            } else if (is_numeric($param)) {
+            } else if (is_number($param)) { // we can not use is_numeric() because it eats leading zeros from strings like 0045646
+                $return .= $param;
+            } else if (is_float($param)) {
                 $return .= $param;
             } else {
                 $param = $this->adodb->qstr($param);
index 8934f2727ded00a5f7fbccc3baad678198ad3754..c35911f2783f40bf4e5c2c77aba984f4bcf1e05b 100644 (file)
@@ -420,7 +420,9 @@ class mysqli_native_moodle_database extends moodle_database {
                 $return .= (int)$param;
             } else if (is_null($param)) {
                 $return .= 'NULL';
-            } else if (is_numeric($param)) {
+            } else if (is_number($param)) { // we can not use is_numeric() because it eats leading zeros from strings like 0045646
+                $return .= $param;
+            } else if (is_float($param)) {
                 $return .= $param;
             } else {
                 $param = $this->mysqli->real_escape_string($param);
@@ -806,6 +808,7 @@ class mysqli_native_moodle_database extends moodle_database {
             array_unshift($params, $newvalue);
         }
         $sql = "UPDATE {$this->prefix}$table SET $newfield $select";
+var_dump($params);
         $rawsql = $this->emulate_bound_params($sql, $params);
 
         $this->query_start($sql, $params, SQL_QUERY_UPDATE);