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 <[email protected]>
To:
"DBIx::Class user and developer list" <[email protected]>
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/[email protected]

_______________________________________________
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/[email protected]

Reply via email to