From: Greg Sabino Mullane Date: Tue, 18 Dec 2007 15:44:18 +0000 (+0000) Subject: Add currentSequenceValue() function. X-Git-Tag: 1.31.0-rc.0~50363 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=7e27f2fa571567415f1ea661dd55eb3a900a8acb;p=lhc%2Fweb%2Fwiklou.git Add currentSequenceValue() function. --- diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index fa0d6dd735..48c99dbd8c 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -797,6 +797,18 @@ class DatabasePostgres extends Database { return $this->mInsertId; } + /** + * Return the current value of a sequence. Assumes it has ben nextval'ed in this session. + */ + function currentSequenceValue( $seqName ) { + $safeseq = preg_replace( "/'/", "''", $seqName ); + $res = $this->query( "SELECT currval('$safeseq')" ); + $row = $this->fetchRow( $res ); + $currval = $row[0]; + $this->freeResult( $res ); + return $currval; + } + /** * Postgres does not have a "USE INDEX" clause, so return an empty string */