Re: Simple newbie question on relationships

[prev] [thread] [next] [Date index for 2004/12/02]

From: William Ross
Subject: Re: Simple newbie question on relationships
Date: 13:48 on 02 Dec 2004
On 2 Dec 2004, at 12:24, Sean Davis wrote:

> As the title implies, I am new to Class::DBI.  I have the following 
> set up (see below--of course, there is a base package...).  However, 
> in a minimal example, it fails.
> <snip>
>
> # -------------------------------------------------------------------
> package ProbeDBI::analysis;
> use base 'ProbeDBI';
>
> __PACKAGE__->table('analysis');
>
> __PACKAGE__->sequence('analysis_analysis_id_seq');
> __PACKAGE__->columns(All => qw/analysis_id db_id platform_id done_date 
> program descripton file/);
> __PACKAGE__->has_a('db', 'ProbeDBI::db' => 'db_id' );

The has_a syntax is wrong: you've got the arguments for a has_many call 
there. You want:

	__PACKAGE__->has_a(column => 'Class::Name');

and so:

	__PACKAGE__->has_a(db_id => 'ProbeDBI::db');

The first argument has to be a column of __PACKAGE__ (hence the error 
message when you had 'db' there), which does makes sense: you're 
basically declaring that the value in column 'db_id' should be treated 
as the id of another object, and that requests for that column should 
return the object if it can be found.

best

will



Simple newbie question on relationships
Sean Davis 12:24 on 02 Dec 2004

Re: Simple newbie question on relationships
William Ross 13:48 on 02 Dec 2004

Re: Simple newbie question on relationships
Tom Hukins 16:04 on 02 Dec 2004

Re: Simple newbie question on relationships
Sean Davis 17:58 on 02 Dec 2004

Re: Simple newbie question on relationships
Tom Hukins 11:21 on 03 Dec 2004

Generated at 12:00 on 04 Dec 2004 by mariachi v0.52