Re: Efficiently finding elements with 0 has_many elements?
[prev]
[thread]
[next]
[Date index for 2005/04/22]
On Fri, Apr 22, 2005 at 10:57:19AM -0400, David Glasser wrote:
> On 4/22/05, Michael Peters <mpeters@xxxxxxxxx.xxx> wrote:
> > dglasser@xxxxx.xxx wrote:
> > One of the nicest things about C::D is that when you try to do something
> > that isn't necessarily built-in or efficient to do in Perl, you can
> > always have the database do it.
> >
> > Something like this should work for you (depending on how you've named
> > your columns):
> >
> > __PACKAGE__->add_constructor(
> > retrieve_all_no_data => 'item.data IS NULL'
> > );
>
> Hmm. So I bet it'll still be something along the lines of that, but
> the issue is that my Item doesn't have a data column -- it's a
> has_many, and the Data have item columns. Can something like this
> still work?
Indeed it can - you'll just need to use a JOIN.
Have a look at http://wiki.class-dbi.com/index.cgi?UsingJoins for more info.
--
Matt S Trout Brag sheet: http://trout.me.uk/services.html
LAMP, Infrastructure Contact: services@xxxxx.xx.xx
and Automation
specialist Do it once. Do it right.