Thomas Bruederli
2013-10-21 f06aa8058b7e32ba32d4551074b6e0b8a300f751
program/include/rcube_mdb2.php
@@ -6,7 +6,10 @@
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
 | See the README file for a full license statement.                     |
 |                                                                       |
 | PURPOSE:                                                              |
 |   PEAR:DB wrapper class that implements PEAR MDB2 functions           |
@@ -91,6 +94,8 @@
            $db_options['disable_smart_seqname'] = true;
            $db_options['seqname_format'] = '%s';
        }
        $this->db_error     = false;
        $this->db_error_msg = null;
        $dbh = MDB2::connect($dsn, $db_options);
@@ -283,7 +288,7 @@
        else {
            $params = (array)$params;
            $q = $this->db_handle->prepare($query, null, $mode=='w' ? MDB2_PREPARE_MANIP : null);
            if ($this->db_handle->isError($q)) {
            if (MDB2::isError($q)) {
                $this->db_error = true;
                $this->db_error_msg = $q->userinfo;
@@ -364,7 +369,7 @@
        $id = $this->db_handle->lastInsertID($table);
        return $this->db_handle->isError($id) ? null : $id;
        return MDB2::isError($id) ? null : $id;
    }
@@ -631,6 +636,8 @@
    {
        $func = '';
        $args = func_get_args();
        if (is_array($args[0]))
            $args = $args[0];
        switch($this->db_provider) {
            case 'mysql':
@@ -641,6 +648,11 @@
            case 'mssql':
            case 'sqlsrv':
                $delim = ' + ';
                // Modify arguments, because + operator requires them to be of type varchar (#1488505)
                // with SQL Server 2012 we can use just CONCAT(), but we need to support older versions
                foreach ($args as $idx => $arg) {
                    $args[$idx] = "CAST($arg AS varchar)";
                }
                break;
            default:
                $delim = ' || ';