[Dbix-class] Datetime format for MySQL and SQLite

Moritz Onken onken at houseofdesign.de
Sun Jan 20 12:49:09 GMT 2008


Have a look at http://search.cpan.org/~jshirley/DBIx-Class-TimeStamp-0.05/lib/DBIx/Class/TimeStamp.pm


Am 20.01.2008 um 13:10 schrieb Fayland Lam:

> well, in product server I'm using MySQL and for test cases I'm using  
> SQLite.
> so I wonder to ask whether there is any suggestion for something  
> like follows:
>
> I have a Foorum::ResultSet::Comment, and in one sub I write
>
>   my $comment = $self->create(
>       {   object_type => $object_type,
>           object_id   => $object_id,
>           author_id   => $user_id,
>           title       => $title,
>           text        => $text,
>           formatter   => $formatter,
>           post_on     => \'NOW()',                  #' SQLite use  
> CURRENT_TIMESTAMP
>           post_ip     => $post_ip,
>           reply_to    => $reply_to,
>           forum_id    => $forum_id,
>           upload_id   => $info->{upload_id} || 0,
>       }
>   );
>
> u know SQLite need use \'CURRENT_TIMESTAMP' instead of \'NOW()'. it  
> will fail when I call prove -l to test this sub.
>
> How do I know $self->schema or result_source is based on SQLite or  
> MySQL?
>
> Any suggestion to deal with this situation?
>
> Thanks.
>
> -- 
> Fayland Lam // http://www.fayland.org/ Foorum based on Catalyst // http://www.foorumbbs.com/
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.rawmode.org




More information about the DBIx-Class mailing list