[phplib] Patch: MySQL and duplicate session records From: Markus Dobel (mdobel <email protected>)
Date: 05/14/01

Hi,

I saw this problem several times here on the mailing list and now had
the same here. With MySQL, affected_rows() returns 0 for updates where
actually no data is changed. (e.g. "update bla set fasel=fasel" affects
all rows but actually changes none.). This happens in phplib, when
session data are stored unchanged *twice* in one second.

The implemented workaround for this is not working, but here's a patch
which should solve the problem.

Regards, Markus

--- cut here ---

@@ -103,14 +103,15 @@
     # no changes to the table data (i.e. UPDATE tbl SET col = 'x', when
     # "col" is _already_ set to 'x') so then,
     # SECOND, query(SELECT...) on the sid to determine if the row is in
- # fact there,
+ # fact there, fetch the result
     # THIRD, verify that there is at least one row present, and if there
     # is not, then
     # FOURTH, insert the row as we've determined that it does not exist.
  
     if ( $this->db->affected_rows() == 0
         && $this->db->query($squery)
- && $this->db->f(1) == 0
+ && $this->db->next_record()
+ && $this->db->f(0) == 0
         && !$this->db->query($iquery)) {
 
         $ret = false;

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>