From: Norbert Buchmuller Date: Wed, 2 Sep 2009 02:19:14 +0000 (+0200) Subject: Rewrote 'SQL functions on the lhs' to use the new SQLA literal SQL + bind feature. X-Git-Tag: v0.08111~19^2~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5084f15645e4f05bb936eed4f87e56ac68e18953;p=dbsrgits%2FDBIx-Class.git Rewrote 'SQL functions on the lhs' to use the new SQLA literal SQL + bind feature. --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 8867e3f..93068d5 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -420,25 +420,24 @@ specification as you would any column: $rs->search({ 'YEAR(date_of_birth)' => 1979 }); -With quoting on, or for a more portable solution, use the C -attribute: +With quoting on, or for a more portable solution, use literal SQL values with +placeholders: - $rs->search({}, { where => \'YEAR(date_of_birth) = 1979' }); + $rs->search(\[ 'YEAR(date_of_birth)', [ dummy => 1979 ] ]); -=begin hidden - -(When the bind args ordering bug is fixed, this technique will be better -and can replace the one above.) - -With quoting on, or for a more portable solution, use the C and -C attributes: + # Equivalent SQL: + # SELECT * FROM employee WHERE YEAR(date_of_birth) = ? - $rs->search({}, { - where => \'YEAR(date_of_birth) = ?', - bind => [ 1979 ] + $rs->search({ + name => 'Bob', + -nest => \[ 'YEAR(date_of_birth)', [ dummy => 1979 ] ], }); -=end hidden + # Equivalent SQL: + # SELECT * FROM employee WHERE name = ? AND YEAR(date_of_birth) = ? + +See also L. =head1 JOINS AND PREFETCHING