[CDBI] has_many self reference

[prev] [thread] [next] [Date index for 2006/02/05]

From: Hunter Thomas
Subject: [CDBI] has_many self reference
Date: 15:37 on 05 Feb 2006
So, I'm trying to do this:

Table def:
CREATE TABLE entry {
id INT PRIMARY KEY,
parent INT
}

Perl code:
package Entry;
use base 'My::DB'; #inherits from Class::DBI::AutoLoader
__PACKAGE__->has_a(parent => 'Entry');
__PACKAGE__->has_many(children => ['Entry', 'parent']);
1;

And I get the error:
Couldn't load "Entry", "Can't locate object method "meta_info" via 
package "Entry" at 
/usr/local/lib/perl5/site_perl/5.8.7/Class/DBI/Relationship/HasMany.pm 
line 34

I've been playing with this, trying to put it after the 1; with the 
__PACKAGE__ as Entry->, and none of it is working, I keep getting the same.

I have collapsed the info above, by the way. I'm trying to make a table 
that stores both the main entries and any comments for a blog (yes, 
another blog, sorry), and this just seemed like the most natural way to 
model it. Any thoughts?

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

[CDBI] has_many self reference
Hunter Thomas 15:37 on 05 Feb 2006

Re: [CDBI] has_many self reference
Perrin Harkins 20:50 on 06 Feb 2006

Re: [CDBI] has_many self reference
Hunter Thomas 14:42 on 07 Feb 2006

Re: [CDBI] has_many self reference
Perrin Harkins 15:05 on 07 Feb 2006

Re: [CDBI] has_many self reference
Aaron Trevena 15:07 on 01 Mar 2006

Re: [CDBI] has_many self reference
Aaron Trevena 15:22 on 01 Mar 2006

Re: [CDBI] has_many self reference
Matt S Trout 15:30 on 01 Mar 2006

Generated at 20:45 on 01 Mar 2006 by mariachi v0.52