From: Norbert Buchmuller Date: Wed, 2 Sep 2009 03:30:35 +0000 (+0200) Subject: Fixed the bind value column names in the SQL literal + bind examples. X-Git-Tag: v0.08111~19^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=49187c4faddf41f920062d3aa8e743191fedd1c6;p=dbsrgits%2FDBIx-Class.git Fixed the bind value column names in the SQL literal + bind examples. --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 6aa9f31..7885f15 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -423,19 +423,24 @@ specification as you would any column: With quoting on, or for a more portable solution, use literal SQL values with placeholders: - $rs->search(\[ 'YEAR(date_of_birth) = ?', [ dummy => 1979 ] ]); + $rs->search(\[ 'YEAR(date_of_birth) = ?', [ date_of_birth => 1979 ] ]); # Equivalent SQL: # SELECT * FROM employee WHERE YEAR(date_of_birth) = ? $rs->search({ name => 'Bob', - -nest => \[ 'YEAR(date_of_birth) = ?', [ dummy => 1979 ] ], + -nest => \[ 'YEAR(date_of_birth) = ?', [ date_of_birth => 1979 ] ], }); # Equivalent SQL: # SELECT * FROM employee WHERE name = ? AND YEAR(date_of_birth) = ? +Note: the C string in the C<< [ date_of_birth => 1979 ] >> part +should be the same as the name of the column. It is used by L to +handle special column types. (If no column is involved in your expression, just +invent a column name.) + See also L. diff --git a/lib/DBIx/Class/Manual/FAQ.pod b/lib/DBIx/Class/Manual/FAQ.pod index cf75fd2..b21fd3a 100644 --- a/lib/DBIx/Class/Manual/FAQ.pod +++ b/lib/DBIx/Class/Manual/FAQ.pod @@ -247,7 +247,12 @@ documentation for details. To use an SQL function on the left hand side of a comparison: - ->search({ -nest => \[ 'YEAR(date_of_birth) = ?', [ dummy => 1979 ] ] }); + ->search({ -nest => \[ 'YEAR(date_of_birth) = ?', [ date_of_birth => 1979 ] ] }); + +Note: the C string in the C<< [ date_of_birth => 1979 ] >> part +should be the same as the name of the column. It is used by L to +handle special column types. (If no column is involved in your expression, just +invent a column name.) Or, if you have quoting off: