Changeset 4886


Ignore:
Timestamp:
02/13/10 22:27:42 (10 years ago)
Author:
nikrou
Message:

Feature 1255 : bug in pwg_session_write() with postgresql.
replace into doesn't exists. Must do two queries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/dblayer/functions_pgsql.inc.php

    r4833 r4886  
    7171  global $conf,$page,$debug,$t2; 
    7272 
     73  $replace_pattern = '`REPLACE INTO\s(\S*)\s*([^)]*\))\s*VALUES\(([^,]*),(.*)\)\s*`mi';   
     74 
    7375  $start = get_moment(); 
    74   ($result = pg_query($query)) or die($query."\n<br>".pg_last_error()); 
     76 
     77  if (preg_match($replace_pattern, $query, $matches) 
     78      && $matches[1]==SESSIONS_TABLE) 
     79  { 
     80    $select_query = ' 
     81SELECT id FROM '.$matches[1].' 
     82  WHERE id='.$matches[3]; 
     83    ( $result = pg_query($select_query)) or die($query."\n<br>".pg_last_error()); 
     84    if (pwg_db_num_rows($result)==1) 
     85    { 
     86      $query = ' 
     87UPDATE '.$matches[1].' 
     88  SET expiration=now() 
     89  WHERE id='.$matches[3]; 
     90    } 
     91    else 
     92    { 
     93      $query = ' 
     94INSERT INTO '.$matches[1].' 
     95  '.$matches[2].' VALUES('.$matches[3].','.$matches[4].')'; 
     96    } 
     97    ( $result = pg_query($query)) or die($query."\n<br>".pg_last_error());       
     98  } 
     99  else  
     100  { 
     101    ($result = pg_query($query)) or die($query."\n<br>".pg_last_error()); 
     102  } 
    75103 
    76104  $time = get_moment() - $start; 
Note: See TracChangeset for help on using the changeset viewer.