diff options
author | nikrou <nikrou@piwigo.org> | 2010-02-15 19:49:04 +0000 |
---|---|---|
committer | nikrou <nikrou@piwigo.org> | 2010-02-15 19:49:04 +0000 |
commit | c1d6177df9ebb853217958d91aba26f35f66a497 (patch) | |
tree | bff2b1998cc4d8030a48a96c39104887066e53dd /include/dblayer/functions_pgsql.inc.php | |
parent | 78b517bde6abed39b858f0854c3fca5d82bed4b9 (diff) |
Feature 1255 :
update pwg_db_insert_id() function.
PosgreSQL needs table name to retrieve last insert auto increment id.
git-svn-id: http://piwigo.org/svn/trunk@4892 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/dblayer/functions_pgsql.inc.php')
-rw-r--r-- | include/dblayer/functions_pgsql.inc.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/dblayer/functions_pgsql.inc.php b/include/dblayer/functions_pgsql.inc.php index 6dcf26f6d..5337b4aa5 100644 --- a/include/dblayer/functions_pgsql.inc.php +++ b/include/dblayer/functions_pgsql.inc.php @@ -192,9 +192,15 @@ function pwg_db_real_escape_string($s) return pg_escape_string($s); } -function pwg_db_insert_id() +function pwg_db_insert_id($table=null, $column='id') { - // select currval('piwigo_user_id_seq'); + $sequence = sprintf('%s_%s_seq', strtolower($table), $column); + $query = ' +SELECT CURRVAL(\''.$sequence.'\');'; + + list($id) = pwg_db_fetch_row(pwg_query($query)); + + return $id; } /** |