Re: FW: [CDBI] ChildOf

[prev] [thread] [next] [Date index for 2005/09/10]

From: Jay Strauss
Subject: Re: FW: [CDBI] ChildOf
Date: 00:29 on 10 Sep 2005
Kate Yoak wrote:
>>This sounds useful, but I don't quite understand from your
>>description how it
>>differs from a has_a relationship from the child to the parent
>>(other than it
>>allows you to specify the accessor name for the parent). What am
>>I missing?
>>
>>I implement similar parent/child relationships like so:
>>
>>Parent->columns('Primary' => qw/parent_id/);
>>Parent->has_many(children => Child);
>>Child->columns('Primary' => qw/child_id/);
>>Child->columns('Others => qw/parent_id/);
>>Child->has_a(parent_id => Parent);
>>
>>How does ChildOf simplify or improve on this?
>>
>>Thanks,
>>Ed
>>
> 
> 
> Good point.  Forgot to explain.  The problem with has_a is that it takes
> your primary column, your object id (that you are probably using everywhere
> in urls, keys, etc) and turns it into a parent object.  That's not very nice
> from two perspectives:
> 
> #1.  I like my id where it is!  :-)  I mean, really - when I say <a
> href="/?a_id=<%$link->link_id%>"> I expect a number to show up. (I believe
> it actually will - because of stringify - but read on).
> 
> #2.  I don't want to go to the database for the parent just because I am
> accessing the child's id.

Is this true?  If you go:

print $child_obj->parent_id, "\n";

I think it just accesses the data in the child as is.

I think you only go back to the DB if you go:

print $child_obj->parent_id->some_col_in_parent, "\n";


And if you are looking for siblings for your current object, with just a 
different where criteria, seems like you could use your current child 
class (maybe throw in Abstract::Search for ease of use)

I've gotta be missing something here
Jay

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

FW: [CDBI] ChildOf
Kate Yoak 00:10 on 10 Sep 2005

Re: FW: [CDBI] ChildOf
Jay Strauss 00:29 on 10 Sep 2005

[CDBI] Re: ChildOf
Edward J. Sabol 00:46 on 10 Sep 2005

[CDBI] RE: ChildOf
Kate Yoak 01:30 on 10 Sep 2005

Generated at 13:57 on 10 Sep 2005 by mariachi v0.52