[Dbix-class] Query translation

Kenneth S Mclane ksmclane at us.ibm.com
Thu May 10 17:34:11 GMT 2012


Ok, I understand how that works I think, but how/where do I integrate it 
into my code as I am using Catalyst models and I'm very confused on this 
one.



From:
fREW Schmidt <frioux at gmail.com>
To:
"DBIx::Class user and developer list" <dbix-class at lists.scsys.co.uk>
Date:
05/10/2012 12:08 PM
Subject:
Re: [Dbix-class] Query translation




SELECT
            s.server_id,
            a.account_code,
            s.server_name,
            s.server_type,
            s.os_name,
            (select count(*) from server ss, subsystem sb
                   where ss.server_id = sb.server_id
                   and ss.server_id = s.server_id) as num_subsystems
           FROM
            account a,
            server s
           WHERE a.account_id = s.account_id
           order by a.account_code, s.server_name

Actually, I just released a helper that will do the correlated subquery 
for you.  Check it out here: 
http://search.cpan.org/~frew/DBIx-Class-Helpers-2.008000/lib/DBIx/Class/Helper/ResultSet/CorrelateRelationship.pm 

-- 
fREW Schmidt
http://blog.afoolishmanifesto.com
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: 
http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120510/e2433937/attachment.htm


More information about the DBIx-Class mailing list