X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FCookbook.pod;h=ce68fc24b8399f272e543a76d14dd61fa07d30cc;hb=e570488a;hp=c18ab66a5663ca7b40bbb95157c91e5390afffe9;hpb=5529838f7afff91467ef2664087999ab222da48d;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index c18ab66..ce68fc2 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -125,9 +125,9 @@ almost like you would define a regular ResultSource. # # do not attempt to deploy() this view - __PACKAGE__->result_source_instance->is_virtual(1); + __PACKAGE__->result_source->is_virtual(1); - __PACKAGE__->result_source_instance->view_definition(q[ + __PACKAGE__->result_source->view_definition(q[ SELECT u.* FROM user u INNER JOIN user_friends f ON u.id = f.user_id WHERE f.friend_user_id = ? @@ -1342,7 +1342,7 @@ row. # Abort the whole job if ($_ =~ /horrible_problem/) { - print "something horrible happend, aborting job!"; + print "something horrible happened, aborting job!"; die $_; # rethrow error } @@ -1737,30 +1737,30 @@ L and L family of methods: $resultset->create({ - numbers => [1, 2, 3] + numbers => [1, 2, 3], }); - $result->update( - { - numbers => [1, 2, 3] - }, - { - day => '2008-11-24' - } - ); + $result->update({ + numbers => [1, 2, 3], + }); In conditions (e.g. C<\%cond> in the L family of methods) you cannot directly use array references (since this is interpreted as a list of values to be Ced), but you can use the following syntax to force passing them as bind values: - $resultset->search( - { - numbers => \[ '= ?', [numbers => [1, 2, 3]] ] - } - ); + $resultset->search({ + numbers => { -value => [1, 2, 3] }, + }); + +Or using the more generic (and more cumbersome) literal syntax: + + $resultset->search({ + numbers => \[ '= ?', [ numbers => [1, 2, 3] ] ] + }); + -See L and 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 @@ -1770,11 +1770,11 @@ 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 +formatted to be understood by your RDBMS, you must use the L 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 +L provides a correct L formatter, so all you have to do is: my $dtf = $schema->storage->datetime_parser; @@ -1793,12 +1793,11 @@ 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 and L, +whereas L and +L (but not L) are L-aware and will do the right thing when supplied -an inflated C object. +an inflated L object. =head2 Using Unicode @@ -2280,3 +2279,14 @@ You can accomplish this with L or L: }); =cut + +=head1 FURTHER QUESTIONS? + +Check the list of L. + +=head1 COPYRIGHT AND LICENSE + +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L.