This is a discussion on auto-update a datetime field in mysql... within the alt.comp.lang.php forums, part of the PHP Programming Forums category; hi guys, me again ! i need to update a record in a mysql table. now i have defined a datetime ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
hi guys,
me again ! i need to update a record in a mysql table. now i have defined a datetime field when a record is modified... i want to 'auto update' that field whenever a record is modified... what would the php script be for something like that... ? thanx, gawie. |
|
|||
|
Gawie Marais wrote:
> me again ! i need to update a record in a mysql table. now i have defined > a datetime field when a record is modified... i want to 'auto update' that > field whenever a record is modified... what would the php script be for > something like that... ? UPDATE tablename SET record1 = 'foo', record2 = 'bar', datefield = now() WHERE record3 = 'xyz' Setting a date or datetime field to now() sets it to the current date and time. -- Chris Hope The Electric Toolbox - http://www.electrictoolbox.com/ |
|
|||
|
"Gawie Marais" <gmlists@gam.co.za> wrote in message
news:cajndp$s81$2@ctb-nnrp2.saix.net... > hi guys, > > me again ! i need to update a record in a mysql table. now i have defined a > datetime field when a record is modified... i want to 'auto update' that > field whenever a record is modified... what would the php script be for > something like that... ? Here's an interesting fact I just learned: mySQL will auto-update the first column with the type of TIMESTAMP. Works like a charm! And you don't have to do or define a thing! Walter |