Re: Is might_have the most efficient way to do this?

[prev] [thread] [next] [Date index for 2004/10/22]

From: Perrin Harkins
Subject: Re: Is might_have the most efficient way to do this?
Date: 16:24 on 22 Oct 2004
On Wed, 2004-10-20 at 10:22, James FitzGibbon wrote:
> Given the following table structure:
> 
> CREATE TABLE foo(
> 	control NUMBER PRIMARY KEY,
> 	foo VARCHAR2(20),
> 	has_bar NUMBER(1),
> 	has_baz NUMBER(1)
> );
> 
> CREATE TABLE bar(
> 	control NUMBER PRIMARY KEY,
> 	bar VARCHAR2(20),
> );
> 
> CREATE TABLE baz(
> 	control NUMBER PRIMARY KEY,
> 	baz VARCHAR2(20),
> );
> 
> I'm trying to set up CDBI to only fetch from tables bar and baz if the value
> of foo.has_bar or foo.has_baz
> is 1.  Is there an idiom for doing this?
[...]
> I have tried using has_a and specifying my own inflate and deflate subs, but
> that gets messy very
> quickly.
> 
> Any ideas on how best to achieve this?

The has_a approach sounds good to me, or you could write your own custom
accessors for bar() checks $self->has_bar() and does a Bar->retrieve()
if it's 1.

- Perrin

Is might_have the most efficient way to do this?
James FitzGibbon 14:22 on 20 Oct 2004

Re: Is might_have the most efficient way to do this?
Perrin Harkins 16:24 on 22 Oct 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52