From: skodak Date: Tue, 13 Jan 2009 13:12:59 +0000 (+0000) Subject: MDL-17880 fixed removing of leading 0 from strings when emulating bounds in DML X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c1a6529be1256e6f12d016889c697d292a86a57e;p=moodle.git MDL-17880 fixed removing of leading 0 from strings when emulating bounds in DML --- diff --git a/lib/dml/adodb_moodle_database.php b/lib/dml/adodb_moodle_database.php index 6ea73e3cd0..703ee48a21 100644 --- a/lib/dml/adodb_moodle_database.php +++ b/lib/dml/adodb_moodle_database.php @@ -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); diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 8934f2727d..c35911f278 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -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);