[Dbix-class] Problem selecting distinct years from date column

Peter Rabbitson rabbit+dbic at rabbit.us
Thu Jan 7 11:08:17 GMT 2010


matthew couchman (JIC) wrote:
> Hi,
> 
> I came back to this problem and I think I've got it sorted now so I thought it might be useful to post the solution in case anybody else was having the same problem. My problem was that quotes were being added to the zero argument. So the revised query looks like this:
> 
> my $years_rs = $c->model($table_name)->search(
>     {
>         date => { '!=', \"0" }
>     },
>     {
>         select => [ \'YEAR(date) AS year' ], 
>     	  as => [ 'year' ], 
>         group_by => [ 'year' ]
>     }
> );
> 

This is not a solution, please do not popularize hideous crap like this
in a public forum.

> My problem was that quotes were being added to the zero argument.

^^ This can not be a problem with placeholders, as quotation is
absolutely irrelevant. I took the time to write a test case and kindly
asked you to try it against your own mysql server. Please do so and
come back with the results.



More information about the DBIx-Class mailing list