From be9aacaa5296dfca63fb3a01c2dc52538d1546aa Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Sat, 17 Nov 2012 12:31:31 -0500
Subject: [PATCH] Bring back lost localization for the about page

---
 program/include/rcube_db.php |   45 +++++++++++++++++++++++++++++++--------------
 1 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/program/include/rcube_db.php b/program/include/rcube_db.php
index 33dcbe9..5d8c4a5 100644
--- a/program/include/rcube_db.php
+++ b/program/include/rcube_db.php
@@ -21,15 +21,16 @@
 
 
 /**
- * Database independent query interface
+ * Database independent query interface.
+ * This is a wrapper for the PHP PDO.
  *
- * This is a wrapper for the PHP PDO
- *
- * @package Database
- * @version 1.0
+ * @package   Framework
+ * @sbpackage Database
  */
 class rcube_db
 {
+    public $db_provider;
+
     protected $db_dsnw;               // DSN for write operations
     protected $db_dsnr;               // DSN for read operations
     protected $db_connected = false;  // Already connected ?
@@ -266,11 +267,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 +389,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 +583,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 +598,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