mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 03:09:58 +03:00
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
This commit is contained in:
parent
78b517bde6
commit
c1d6177df9
10 changed files with 20 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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']))
|
||||
|
|
|
@ -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']))
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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'])
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue