[Catalyst] More complex Class::DBI::Sweet usage?
Matt S Trout
catalyst at trout.me.uk
Sat Jul 2 02:24:32 CEST 2005
On Thu, Jun 30, 2005 at 11:32:51PM -0400, Perrin Harkins wrote:
> On Thu, 2005-06-30 at 16:44 -0700, Jules Agee wrote:
> > Would it make sense to use Class::DBI::Sweet in this example? If not,
> > what approach would you use? I've got five tables, and the ipaddr and
> > login tables are populated automatically from log files. I want to be
> > able to see what systems a particular user logs in from, and which users
> > are logging in from a particular system, either way.
>
> What problem are you trying to solve? How to write a report with
> Class::DBI? Ideally, don't use Class::DBI for it -- just write the SQL.
> If you really want to use Class::DBI, and the end result can be a list
> of objects of one type, add a custom query using set_sql to the class of
> the object you want to get back. For example, add a search_by_system()
> query to your User class. It should do the joins across the tables in
> between.
The 0.03 release of Class::DBI::Sweet can currently only auto-join by one
step (i.e. to tables related directly to the current one), so for the
moment I think you're correct[0].
If you were looking to connect across only 3 tables though, I'd say use
Sweet - with the ActiveRecord-:include-style prefetch facility it provides
it's far less hassle than messing about with set_sql.
[0] I'm going to do arbitrary-step auto-joins as soon as I have time. Watch
This Space (and CPAN :)
--
Matt S Trout Website: http://www.shadowcatsystems.co.uk
Technical Director E-mail: mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.
More information about the Catalyst
mailing list