From 35cdf9771f57726bbded131d7252c3d028e18a4f Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Thu, 04 Oct 2012 04:02:36 -0400
Subject: [PATCH] Bring back lost localization files
---
program/include/rcube_db.php | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/program/include/rcube_db.php b/program/include/rcube_db.php
index 33dcbe9..eb1ad31 100644
--- a/program/include/rcube_db.php
+++ b/program/include/rcube_db.php
@@ -266,11 +266,17 @@
/**
* Getter for error state
*
- * @return boolean True on error
+ * @param int $res_id Optional query result identifier
+ *
+ * @return string Error message
*/
- public function is_error()
+ public function is_error($res_id = null)
{
- return $this->db_error ? $this->db_error_msg : false;
+ if ($res_id !== null) {
+ return $this->_get_result($res_id) === false ? $this->db_error_msg : null;
+ }
+
+ return $this->db_error ? $this->db_error_msg : null;
}
/**
@@ -382,13 +388,19 @@
$idx = 0;
while ($pos = strpos($query, '?', $pos)) {
- $val = $this->quote($params[$idx++]);
- unset($params[$idx-1]);
- $query = substr_replace($query, $val, $pos, 1);
- $pos += strlen($val);
+ if ($query[$pos+1] == '?') { // skip escaped ?
+ $pos += 2;
+ }
+ else {
+ $val = $this->quote($params[$idx++]);
+ unset($params[$idx-1]);
+ $query = substr_replace($query, $val, $pos, 1);
+ $pos += strlen($val);
+ }
}
- $query = rtrim($query, ';');
+ // replace escaped ? back to normal
+ $query = rtrim(strtr($query, array('??' => '?')), ';');
$this->debug($query);
@@ -570,6 +582,10 @@
return intval($input);
}
+ if (is_null($input)) {
+ return 'NULL';
+ }
+
// create DB handle if not available
if (!$this->dbh) {
$this->db_connect('r');
@@ -581,7 +597,7 @@
'integer' => PDO::PARAM_INT,
);
$type = isset($map[$type]) ? $map[$type] : PDO::PARAM_STR;
- return $this->dbh->quote($input, $type);
+ return strtr($this->dbh->quote($input, $type), array('?' => '??')); // escape ?
}
return 'NULL';
--
Gitblit v1.9.1