tags:

views:

124

answers:

1

Here's a snippet of my PHP that is creating the table:

$sql = 'CREATE TABLE '.$table.' (
       `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
       `name` VARCHAR( 55 ) NOT NULL ,
       `venue` VARCHAR( 55 ) NOT NULL ,
       `time` TIMESTAMP NOT NULL ,
       `desc` TEXT NOT NULL
       )';

This is making the time column become the current timestamp when I add or change a row. How can I prevent this?

+8  A: 

That's the default behavior of the TIMESTAMP column type. I'd recommend changing it to a DATETIME column.

You can also alter the behavior by explicitly specifying how you want it to behave.

added TIMESTAMP DEFAULT CURRENT_TIMESTAMP

The above column specification will not have the ON UPDATE behavior. You can also specify a NULL value or 0 as the default.

Blixt