| | |
| | | * @author David Saez Padros <david@ols.es> |
| | | * @author Thomas Bruederli <roundcube@gmail.com> |
| | | * @author Lukas Kahwe Smith <smith@pooteeweet.org> |
| | | * @version 1.17 |
| | | * @version 1.18 |
| | | * @link http://pear.php.net/package/MDB2 |
| | | */ |
| | | class rcube_mdb2 |
| | |
| | | |
| | | $this->db_handle = $this->dsn_connect($dsn); |
| | | $this->db_connected = !PEAR::isError($this->db_handle); |
| | | $this->db_mode = $mode; |
| | | |
| | | if ($this->db_connected) |
| | | $this->db_mode = $mode; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | raise_error(array('code' => 500, 'type' => 'db', |
| | | 'line' => __LINE__, 'file' => __FILE__, |
| | | 'message' => $this->db_error_msg), true, true); |
| | | 'message' => $this->db_error_msg), true, false); |
| | | |
| | | $result = false; |
| | | } |
| | | else { |
| | | $result = $q->execute($params); |
| | |
| | | */ |
| | | function num_rows($res_id=null) |
| | | { |
| | | if (!$this->db_handle) |
| | | if (!$this->db_connected) |
| | | return false; |
| | | |
| | | if ($result = $this->_get_result($res_id)) |
| | |
| | | */ |
| | | function affected_rows($res_id = null) |
| | | { |
| | | if (!$this->db_handle) |
| | | if (!$this->db_connected) |
| | | return false; |
| | | |
| | | return (int) $this->_get_result($res_id); |
| | | return $this->_get_result($res_id); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | function insert_id($table = '') |
| | | { |
| | | if (!$this->db_handle || $this->db_mode == 'r') |
| | | if (!$this->db_connected || $this->db_mode == 'r') |
| | | return false; |
| | | |
| | | if ($table) { |
| | |
| | | if (!$this->db_handle) |
| | | $this->db_connect('r'); |
| | | |
| | | return $this->db_handle->quote($input, $type); |
| | | return $this->db_connected ? $this->db_handle->quote($input, $type) : addslashes($input); |
| | | } |
| | | |
| | | |
| | |
| | | if (!$this->db_handle) |
| | | $this->db_connect('r'); |
| | | |
| | | return $this->db_handle->quoteIdentifier($str); |
| | | return $this->db_connected ? $this->db_handle->quoteIdentifier($str) : $str; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | function fromunixtime($timestamp) |
| | | { |
| | | switch($this->db_provider) { |
| | | case 'mysqli': |
| | | case 'mysql': |
| | | case 'sqlite': |
| | | return sprintf("FROM_UNIXTIME(%d)", $timestamp); |
| | | |
| | | default: |
| | | return date("'Y-m-d H:i:s'", $timestamp); |
| | | } |
| | | return date("'Y-m-d H:i:s'", $timestamp); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | private function _sqlite_prepare() |
| | | { |
| | | include_once('include/rcube_sqlite.inc'); |
| | | include_once(INSTALL_PATH . 'program/include/rcube_sqlite.inc'); |
| | | |
| | | // we emulate via callback some missing MySQL function |
| | | sqlite_create_function($this->db_handle->connection, |