[Catalyst] Looking For Better Way To Handle SQL LEFT JOIN Situation

Bill Moseley moseley at hank.org
Sat Mar 11 07:02:39 CET 2006


On Fri, Mar 10, 2006 at 08:22:50PM -0500, hkclark at gmail.com wrote:
> SELECT s.name, s.ip_address, s.country, s.state, s.owner, count(a.id)
> AS appcount FROM server s LEFT JOIN application a ON s.name = a.server
> GROUP BY s.name;
> 
> That allows me hit the database a single time and get everything I
> need, but as soon as I do that I lose the cool
> "Class::DBI::Plugin::Pager" feature (and probably a lot of other stuff
> I haven't realized yet).

In CDBI there's two methods I use:

1) Create a view and a separate class for the view -- that view class
often inherits from the class the view mostly represents (Server
class in your example above).

2) Create custom set_sql as described in Class::DBI::Sweet

I suspect this is even easier with DBIx::Class.

-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list