auto-update a datetime field in mysql...

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-14-2004
Gawie Marais
 
Posts: n/a
Default auto-update a datetime field in mysql...

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.


Reply With Quote
  #2 (permalink)  
Old 06-14-2004
Chris Hope
 
Posts: n/a
Default Re: auto-update a datetime field in mysql...

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/
Reply With Quote
  #3 (permalink)  
Old 06-15-2004
jsWalter
 
Posts: n/a
Default Re: auto-update a datetime field in mysql...

"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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:03 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0