diff options
Diffstat (limited to 'include/dblayer')
-rw-r--r-- | include/dblayer/functions_mysql.inc.php | 2 | ||||
-rw-r--r-- | include/dblayer/functions_pgsql.inc.php | 10 | ||||
-rw-r--r-- | include/dblayer/functions_sqlite.inc.php | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php index 6a29a0e40..f94984514 100644 --- a/include/dblayer/functions_mysql.inc.php +++ b/include/dblayer/functions_mysql.inc.php @@ -157,7 +157,7 @@ function pwg_db_real_escape_string($s) return mysql_real_escape_string($s); } -function pwg_db_insert_id() +function pwg_db_insert_id($table=null, $column='id') { return mysql_insert_id(); } 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; } /** diff --git a/include/dblayer/functions_sqlite.inc.php b/include/dblayer/functions_sqlite.inc.php index 1e25305e9..44b33685c 100644 --- a/include/dblayer/functions_sqlite.inc.php +++ b/include/dblayer/functions_sqlite.inc.php @@ -214,7 +214,7 @@ function pwg_db_real_escape_string($s) return $pwg_db_link->escapeString($s); } -function pwg_db_insert_id() +function pwg_db_insert_id($table=null, $column='id') { global $pwg_db_link; |