Page 1 of 1

table column value gets updated automatically

Posted: Tue Aug 03, 2004 7:24 am
by jasongr
Hello I have the following table definition:

Code: Select all

CREATE TABLE session_info (
  SessionID INT UNSIGNED NOT NULL AUTO_INCREMENT,
  Param VARCHAR(255) NOT NULL,
  Expiration TIMESTAMP NOT NULL,
PRIMARY KEY (SessionID)
) ENGINE=MYISAM DEFAULT CHARSET=latin1;
I set the expiration using the following query:

Code: Select all

$expiration = time() + 7200;
UPDATE session_info SET Expiration = FROM_UNIXTIME($expiration) WHERE SessionID = 5;
I can check the database and I see that the expiration value has been changed, by calling:

Code: Select all

select UNIX_TIMESTAMP(Expiration) Expiration from session_info where SessionID = 5;
Later in the code I call the following query:

Code: Select all

UPDATE session_info SET Param= 'aaa' WHERE SessionID = 5;
After this query runs, I see that the Param values gets changed to 'aaa', BUT the Expiration column gets changed too -> to the current timestamp!, and the previous value has been lost!

Is this how things are suppose to happen?
I thought that the Expiration column shouldn't change.

thanks

Posted: Tue Aug 03, 2004 7:28 am
by markl999

Posted: Tue Aug 03, 2004 8:01 am
by jasongr
thanks for the help
The link was very useful