On 3/15/07 6:14 AM, Danial Pearce wrote:
>> But if I choose the NOT NULL route, then surely I will still need a special
>> check i.e. if ($date ne '0000-00-00')
> 
> RDBO uses DateTime to handle it's objects I believe. YMMV but I think
> it may handle the 0000-00-00 case under the hood.

0000-00-00  cannot be inflated into a DateTime object.  Rose::DB (and by
extension, RDBO) treats 0000-00-00 as a literal "keyword" for MySQL.  That
is, it'll pass a value of 0000-00-00 through to MySQL untouched, and it will
pull such values from the database and leave them as uninflated literal
strings.

I recommend against using 0000-00-00 values.  There's no sensible way to get
a DateTime object from them, and there's no generally agreed upon meaning
for them.  Decide what you really mean by 0000-00-00 and use something more
appropriate.

For example, if you mean "there is no value for this date", then use NULL.
If you mean "the earliest possible date" then switch to Postgres and use
"-infinity" (which does inflate to a nice DateTime object, BTW :) or pick
some canonical (but still valid) "earliest date" (e.g., 1900-01-01) and
assign it to a constant or global function or method so it's easy to use in
your app.

-John



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to