[Dbix-class] Problems using a database function in the where clause

Jason Gottshall jgottshall at capwiz.com
Wed Jul 23 19:16:00 BST 2008


Moritz Onken wrote:
>>>>> $rs->search({
>>>>> -and =>
>>>>> [
>>>>>  {\"extract(year from age(NOW(),birthday))" => 22},
>>>>>  {sex => "male"}
>>>>> ]
>>>>> });
>>
>> Have you tried the other way around?
>>
>> -and =>  [
>>   { '' => \'extract(year from age(NOW(),birthday))'},
>>   {sex => "male"}
>> ]
>>
>> I couldn't understand what is the 22 doing there.
> 
> This query fetches all males who are 22 years old (postgresql syntax).

Ok, so put the 22 on the left and see what happens (untested):

   $rs->search({
     22  => \'extract(year from age(NOW(),birthday))',
     sex => "male"
   });








More information about the DBIx-Class mailing list