mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
Feature 1255 : bug in pwg_session_write() with postgresql.
replace into doesn't exists. Must do two queries git-svn-id: http://piwigo.org/svn/trunk@4886 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -70,8 +70,36 @@ function pwg_query($query)
|
|||||||
{
|
{
|
||||||
global $conf,$page,$debug,$t2;
|
global $conf,$page,$debug,$t2;
|
||||||
|
|
||||||
|
$replace_pattern = '`REPLACE INTO\s(\S*)\s*([^)]*\))\s*VALUES\(([^,]*),(.*)\)\s*`mi';
|
||||||
|
|
||||||
$start = get_moment();
|
$start = get_moment();
|
||||||
($result = pg_query($query)) or die($query."\n<br>".pg_last_error());
|
|
||||||
|
if (preg_match($replace_pattern, $query, $matches)
|
||||||
|
&& $matches[1]==SESSIONS_TABLE)
|
||||||
|
{
|
||||||
|
$select_query = '
|
||||||
|
SELECT id FROM '.$matches[1].'
|
||||||
|
WHERE id='.$matches[3];
|
||||||
|
( $result = pg_query($select_query)) or die($query."\n<br>".pg_last_error());
|
||||||
|
if (pwg_db_num_rows($result)==1)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.$matches[1].'
|
||||||
|
SET expiration=now()
|
||||||
|
WHERE id='.$matches[3];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
INSERT INTO '.$matches[1].'
|
||||||
|
'.$matches[2].' VALUES('.$matches[3].','.$matches[4].')';
|
||||||
|
}
|
||||||
|
( $result = pg_query($query)) or die($query."\n<br>".pg_last_error());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
($result = pg_query($query)) or die($query."\n<br>".pg_last_error());
|
||||||
|
}
|
||||||
|
|
||||||
$time = get_moment() - $start;
|
$time = get_moment() - $start;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user