aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/history.php4
-rw-r--r--admin/include/functions.php6
-rw-r--r--include/dblayer/functions_mysql.inc.php2
-rw-r--r--include/dblayer/functions_pgsql.inc.php10
-rw-r--r--include/dblayer/functions_sqlite.inc.php2
-rw-r--r--include/functions_comment.inc.php2
-rw-r--r--include/ws_functions.inc.php2
-rw-r--r--qsearch.php2
-rw-r--r--search.php2
-rw-r--r--upload.php2
10 files changed, 20 insertions, 14 deletions
diff --git a/admin/history.php b/admin/history.php
index 86014fc7b..b0022b902 100644
--- a/admin/history.php
+++ b/admin/history.php
@@ -136,7 +136,7 @@ INSERT INTO '.SEARCH_TABLE.'
;';
pwg_query($query);
- $search_id = pwg_db_insert_id();
+ $search_id = pwg_db_insert_id(SEARCH_TABLE);
redirect(
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
@@ -198,7 +198,7 @@ INSERT INTO '.SEARCH_TABLE.'
;';
pwg_query($query);
- $search_id = pwg_db_insert_id();
+ $search_id = pwg_db_insert_id(SEARCH_TABLE);
redirect(
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
diff --git a/admin/include/functions.php b/admin/include/functions.php
index d77b2cb81..5cfbf94f0 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1254,7 +1254,7 @@ SELECT id, uppercats, global_rank, visible, status
array($insert)
);
- $inserted_id = pwg_db_insert_id();
+ $inserted_id = pwg_db_insert_id(CATEGORIES_TABLE);
$query = '
UPDATE
@@ -1387,7 +1387,7 @@ SELECT id
)
);
- $page['tag_id_from_tag_name_cache'][$tag_name] = pwg_db_insert_id();
+ $page['tag_id_from_tag_name_cache'][$tag_name] = pwg_db_insert_id(TAGS_TABLE);
}
else
{
@@ -1662,7 +1662,7 @@ SELECT id
)
);
- $inserted_id = pwg_db_insert_id();
+ $inserted_id = pwg_db_insert_id(TAGS_TABLE);
return array(
'info' => sprintf(
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;
diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php
index f22aa3f6e..c4f021edf 100644
--- a/include/functions_comment.inc.php
+++ b/include/functions_comment.inc.php
@@ -168,7 +168,7 @@ INSERT INTO '.COMMENTS_TABLE.'
pwg_query($query);
- $comm['id'] = pwg_db_insert_id();
+ $comm['id'] = pwg_db_insert_id(COMMENTS_TABLE);
if (($comment_action=='validate' and $conf['email_admin_on_comment']) or
($comment_action!='validate' and $conf['email_admin_on_comment_validation']))
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 4a9208905..b3b90a027 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -1247,7 +1247,7 @@ SELECT
array($insert)
);
- $image_id = pwg_db_insert_id();
+ $image_id = pwg_db_insert_id(IMAGES_TABLE);
// let's add links between the image and the categories
if (isset($params['categories']))
diff --git a/qsearch.php b/qsearch.php
index feb549b55..162686381 100644
--- a/qsearch.php
+++ b/qsearch.php
@@ -60,7 +60,7 @@ INSERT INTO '.SEARCH_TABLE.'
(\''.addslashes(serialize($search)).'\', NOW() )
;';
pwg_query($query);
- $search_id = pwg_db_insert_id();
+ $search_id = pwg_db_insert_id(SEARCH_TABLE);
}
redirect(
diff --git a/search.php b/search.php
index 6f9ae5af3..4a009ae23 100644
--- a/search.php
+++ b/search.php
@@ -148,7 +148,7 @@ INSERT INTO '.SEARCH_TABLE.'
;';
pwg_query($query);
- $search_id = pwg_db_insert_id();
+ $search_id = pwg_db_insert_id(SEARCH_TABLE);
}
else
{
diff --git a/upload.php b/upload.php
index 5e595f90c..94591cf03 100644
--- a/upload.php
+++ b/upload.php
@@ -248,7 +248,7 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) )
$query.= ",'".$_POST['mail_address']."',".time().",'".$xml_infos."')";
$query.= ';';
pwg_query( $query );
- $page['waiting_id'] = pwg_db_insert_id();
+ $page['waiting_id'] = pwg_db_insert_id(WAITING_TABLE);
if ($conf['email_admin_on_picture_uploaded'])
{