From 0d94fd45f422fe0d0460f5db7a7761f56bc18236 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 19 Jun 2012 10:46:41 +0200 Subject: New database layer based on PHP PDO --- program/include/rcube_db_pgsql.php | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 program/include/rcube_db_pgsql.php (limited to 'program/include/rcube_db_pgsql.php') diff --git a/program/include/rcube_db_pgsql.php b/program/include/rcube_db_pgsql.php new file mode 100644 index 000000000..63bd92b40 --- /dev/null +++ b/program/include/rcube_db_pgsql.php @@ -0,0 +1,89 @@ + | + +-----------------------------------------------------------------------+ +*/ + + +/** + * Database independent query interface + * + * This is a wrapper for the PHP PDO + * + * @package Database + * @version 1.0 + */ +class rcube_db_pgsql extends rcube_db +{ + + /** + * Get last inserted record ID + * For Postgres databases, a table name is required + * + * @param string $table Table name (to find the incremented sequence) + * + * @return mixed ID or false on failure + */ + public function insert_id($table = '') + { + if (!$this->db_connected || $this->db_mode == 'r') { + return false; + } + + if ($table) { + $table = $this->sequence_name($table); + } + + $id = $this->dbh->lastInsertId($table); + + return $id; + } + + + /** + * Return SQL statement to convert a field value into a unix timestamp + * + * This method is deprecated and should not be used anymore due to limitations + * of timestamp functions in Mysql (year 2038 problem) + * + * @param string $field Field name + * + * @return string SQL statement to use in query + * @deprecated + */ + public function unixtimestamp($field) + { + return "EXTRACT (EPOCH FROM $field)"; + } + + + /** + * Return SQL statement for case insensitive LIKE + * + * @param string $column Field name + * @param string $value Search value + * + * @return string SQL statement to use in query + */ + public function ilike($column, $value) + { + return $this->quote_identifier($column).' ILIKE '.$this->quote($value); + } + +} -- cgit v1.2.3