Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move sequence_name() method into postgres driver class
  • Loading branch information
alecpl committed Jul 8, 2012
1 parent 3d231c8 commit 8e926e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
23 changes: 0 additions & 23 deletions program/include/rcube_db.php
Expand Up @@ -416,7 +416,6 @@ public function affected_rows($res_id = null)

/**
* Get last inserted record ID
* For Postgres databases, a sequence name is required
*
* @param string $table Table name (to find the incremented sequence)
*
Expand Down Expand Up @@ -807,28 +806,6 @@ public function table_name($table)
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;
}

/**
* MDB2 DSN string parser
*
Expand Down
24 changes: 22 additions & 2 deletions program/include/rcube_db_pgsql.php
Expand Up @@ -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;
Expand All @@ -54,6 +53,27 @@ public function insert_id($table = '')
return $id;
}

/**
* 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
*
Expand Down

0 comments on commit 8e926e6

Please sign in to comment.