X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FCookbook.pod;h=6bbd343867991775e9b063a9a21ca6042225940d;hp=3c080046f92a0dfec85174d5084fd2b942adeaca;hb=0ac0af6c62637a5fdb06ecfb8ba4b60f93bf9d75;hpb=ede573ac79427d9905685866142e19074478994c diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 3c08004..6bbd343 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1731,8 +1731,41 @@ See L and L for more explanation. Note that L sets L to C, so you must pass the bind values (the C<[1, 2, 3]> arrayref in the above example) wrapped in -arrayrefs together with the column name, like this: C<< [column_name => value] ->>. +arrayrefs together with the column name, like this: +C<< [column_name => value] >>. + +=head2 Formatting DateTime objects in queries + +To ensure C conditions containing L arguments are properly +formatted to be understood by your RDBMS, you must use the C +formatter returned by L to format +any L objects you pass to L +conditions. Any L object attached to your +L provides a correct C formatter, so +all you have to do is: + + my $dtf = $schema->storage->datetime_parser; + my $rs = $schema->resultset('users')->search( + { + signup_date => { + -between => [ + $dtf->format_datetime($dt_start), + $dtf->format_datetime($dt_end), + ], + } + }, + ); + +Without doing this the query will contain the simple stringification of the +C object, which almost never matches the RDBMS expectations. + +This kludge is necessary only for conditions passed to +L, whereas +L, +L, +L (but not L) are all +L-aware and will do the right thing when supplied +an inflated C object. =head2 Using Unicode