From 8e926e6201dbd8876ed26c9a4b3af5d7079d6247 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sun, 08 Jul 2012 05:10:28 -0400 Subject: [PATCH] Move sequence_name() method into postgres driver class --- program/include/rcube_db.php | 23 ----------------------- program/include/rcube_db_pgsql.php | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/program/include/rcube_db.php b/program/include/rcube_db.php index f24e959..31385d8 100644 --- a/program/include/rcube_db.php +++ b/program/include/rcube_db.php @@ -416,7 +416,6 @@ /** * Get last inserted record ID - * For Postgres databases, a sequence name is required * * @param string $table Table name (to find the incremented sequence) * @@ -805,28 +804,6 @@ } return $table; - } - - /** - * Return correct name for a specific database sequence - * (used for Postgres only) - * - * @param string $sequence Secuence name - * - * @return string Translated sequence name - */ - public function sequence_name($sequence) - { - $rcube = rcube::get_instance(); - - // return sequence name if configured - $config_key = 'db_sequence_'.$sequence; - - if ($name = $rcube->config->get($config_key)) { - return $name; - } - - return $sequence; } /** diff --git a/program/include/rcube_db_pgsql.php b/program/include/rcube_db_pgsql.php index 782fc0e..285b8e2 100644 --- a/program/include/rcube_db_pgsql.php +++ b/program/include/rcube_db_pgsql.php @@ -33,13 +33,12 @@ { /** * 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 = '') + public function insert_id($table = null) { if (!$this->db_connected || $this->db_mode == 'r') { return false; @@ -55,6 +54,27 @@ } /** + * Return correct name for a specific database sequence + * + * @param string $sequence Secuence name + * + * @return string Translated sequence name + */ + protected function sequence_name($sequence) + { + $rcube = rcube::get_instance(); + + // return sequence name if configured + $config_key = 'db_sequence_'.$sequence; + + if ($name = $rcube->config->get($config_key)) { + return $name; + } + + return $sequence; + } + + /** * 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 -- Gitblit v1.9.1