SLUG Mailing List Archives
Re: [SLUG] fustrations with mysql (TIMESTAMP)
- To: Michael Fox <michael@xxxxxxxxxx>
- Subject: Re: [SLUG] fustrations with mysql (TIMESTAMP)
- From: James Gregory <james@xxxxxxxxxxxx>
- Date: Tue Dec 17 16:07:05 2002
- Cc: slug@xxxxxxxxxxx
On Tue, 2002-12-17 at 04:21, Michael Fox wrote:
> Can anyone put me out of my misery and solve this for me, as I've read and
> read yet still can't get something to work.
Unlike PostgreSQL, MySQL does not have this functionality. The keyword
you're looking for is probably CURRENT_DATE (or CURRENT_TIME or
something similar), but you can't set it as a default.
I have spent conclusively too much of my time attempting to wrap
database functionality in my code so it can run on MySQL. This was one
of the many problems. The best thing I could do was to get the wrapper
to set the value CURRENT_DATE if the field was called "createdate" and
no other value was set for that field (it's code which amongst other
things takes a hash of data and puts it in the database. It knows what
fields are in the table.).
note: there is probably a way to make it do it by building in one of the
many bizarro "options" that mysql has these days. That's not such a good
answer though, because it will make your code less portable.