You are here: Re: phpmyadmin/MySQL - dynamic date field? « PHP Programming Language « IT news, forums, messages
Re: phpmyadmin/MySQL - dynamic date field?

Posted by Gordon Burditt on 04/24/06 03:12

>I'm doing a php/MySQL page that reads data out of a MySQL database.
>Longer term, I'll do a data-entry screen allowing me to modify the
>database or add new records. For now, I'm just using phpmyadmin to data
>enter stuff.

>Is there a way to set up a date field, Last_Update, that would
>automatically update to today's date any time a record was added or
>changed using phpmyadmin?

This is the purpose of the field type 'timestamp'. If you want
only the date portion, you can get it with date_format() in the
MySQL query.

The *first* timestamp field will be updated to the current time if
the record is changed, and that field isn't explicitly set. If a
record is inserted, the timestamp field will be the current time
unless another non-null value is explicitly inserted (insert null
or leave the field out of the field list for insert).

Leave off the "using phpmyadmin" part. You get that behavior if
the record is changed with a query, with or without phpmyadmin.
*Can* you modify just one field with phpmyadmin? If you type in
an explicit query, yes, if you use neato GUI stuff, you may be
setting all the fields you didn't change back to the values they
had before, which defeats the action of the timestamp.

Gordon L. Burditt

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация