diff options
author | Aleksander Machniak <alec@alec.pl> | 2012-07-08 11:10:28 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2012-07-08 11:10:28 +0200 |
commit | 8e926e6201dbd8876ed26c9a4b3af5d7079d6247 (patch) | |
tree | 6dd5872680225ed30c1811f676328435e28fcba0 /program/include/rcube_db_pgsql.php | |
parent | 3d231c88fa299787fe52e00773d03a4efa51590d (diff) |
Move sequence_name() method into postgres driver class
Diffstat (limited to 'program/include/rcube_db_pgsql.php')
-rw-r--r-- | program/include/rcube_db_pgsql.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/program/include/rcube_db_pgsql.php b/program/include/rcube_db_pgsql.php index 782fc0ebb..285b8e2d4 100644 --- a/program/include/rcube_db_pgsql.php +++ b/program/include/rcube_db_pgsql.php @@ -33,13 +33,12 @@ 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 = '') + public function insert_id($table = null) { if (!$this->db_connected || $this->db_mode == 'r') { return false; @@ -55,6 +54,27 @@ class rcube_db_pgsql extends rcube_db } /** + * 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 |