[Dbix-class] Issues with using the as=>[...] parameter

Devin Austin devin.austin at gmail.com
Thu Nov 2 23:54:50 GMT 2006


so if i'm understanding this correctly, the following code:

> my $user =3D $schema->resultset('User')->single(
>       {
>           username =3D> $q->param('username'),
>           password =3D> $q->param('password')
>       },
>       {
>         select =3D> [
>           \'userid, COUNT(*) as is_authorized',
>         ],
>       }
>     );


should produce "SELECT userid,  COUNT(*) as is_authorized FROM user WHERE
username=3D? and password=3D?". Correct?


On 11/2/06, Brandon Black <blblack at gmail.com> wrote:
>
> On 11/2/06, John Napiorkowski <jjn1056 at yahoo.com> wrote:
> > Hi,
> >
> > Not sure if I am doing this correctly.  I am trying to
> > order a result by the count of something but the 'as'
> > parameter doesn't seem to do what I think it should
> > do:
>
> [...]
>
> > Can anyone spot what I am doing wrong here?
>
> From:
> http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#as :
>
> Please note: This will NOT insert an AS employee_count into the SQL
> statement produced, it is used for internal access only. Thus
> attempting to use the accessor in an order_by clause or similar will
> fail miserably.
>
> To get around this limitation, you can supply literal SQL to your
> select attibute that contains the AS alias text, eg:
>
>   select =3D> [\'myfield AS alias']
>
> -- Brandon
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
> http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>



-- =

timorperfectus.com - web design to frightening perfection.


One last song
Given to an Angel's Son
As soon as you were gone
As soon as you were gone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061102/23c=
683dc/attachment.htm


More information about the Dbix-class mailing list