On 5/25/06, Perrin Harkins <[EMAIL PROTECTED]> wrote:
On Thu, 2006-05-25 at 13:26 -0400, Guillermo Roditi wrote:
Basically the promblem is that I want default for a column to be
NOW(). unfortunately that is getting insterted as 0000-00-00 so my
guess is that it's getting screwed up in the placeholder stage, and I
can't just do default => DateTime->now... so i thought of doing
default => sub {return DateTime->now; }
Is there some reason why you don't want to just have the database do
this for you automatically? It's easy to do in MySQL.
Yeah, that's the other option, and the one I use most of the time.
Another option is to set the default value to 'now' (no parens) which
has no meaning to MySQL but is a parsable value for
Rose::DateTime::Util::parse_date(), which will evaluate it at the time
the default value is inflated. If you create the object and then save
without ever fetching the datetime value, then the "now" default will
be evaluated during the save() operation.
I'd still rather have the db do it, but the 'now' technique has the
advantage that the object attribute will have the correct value after
the save(). In the other cases, you'd have to re-load() the object to
pull out the value that was automatically added by the database on
insert.
-John
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object