Re: Question on how to implement Class::DBI with crossover tables..
[prev]
[thread]
[next]
[Date index for 2005/03/02]
--=-og20eCVosFAkrxqNUQVj
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
That won't quite work though, beause the Vendor table has no reference
to CTCTID. The connection to a Contact is through another table, one
that I'd like to abstract into not having to deal with. The normal
has_many would work great if the Vendor table had that connection, but
it doesn't. What I want to do is abstract it far enough that I can treat
the Vendor::Contact class as if it had that relationship.
Right now, I could do this:
Vendor->has_many(crossovers=>['Vendor::Crossover'=>'VNDRID']);
and
Vendor::Crossover->has_many(contacts=>['Vendor::Contact'=>'CTCTID']);
but I want the crossover table to be automatically populated just by
editing/adding the Vendor::Contact and Vendor records.
Your example would work fine otherwise. Thank you.
d. Taylor Singletary
On Wed, 2005-03-02 at 21:01 +0000, William Ross wrote:
>
>The other options mentioned here will no doubt offer more, but your
>immediate need is more easily met like this:
>
> Vendor->has_many(contacts => [ 'Vendor::Contact' => 'CTCTID' ]);
>
>It's in the Class::DBI docs under relationships/has_many/mapping. I
>think you still need to have a Vendor::Contact package in your tree,
>but you don't have to worry about its relationships or even columns
>unless you decide to start holding more information there.
>
>best
>
>will
>
>
>
>
>>
>> Is it possible with Class::DBI to semi-transparently manage the
>> crossover tables and still assert relationships like Vendor::Contact,
>> Customer::Contact? How is that done? When accessing these objects I
>> don't want to have to think about maintaining the relationships in the
>> crossover tables at all. Customers can have many contacts, Vendors can
>> have many contacts.
>>
>> Thanks for a push in the right direction on this.
>>
>> d. Taylor Singletary
--=-og20eCVosFAkrxqNUQVj
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.5.6">
</HEAD>
<BODY>
That won't quite work though, beause the Vendor table has no reference to CTCTID. The connection to a Contact is through another table, one that I'd like to abstract into not having to deal with. The normal has_many would work great if the Vendor table had that connection, but it doesn't. What I want to do is abstract it far enough that I can treat the Vendor::Contact class as if it had that relationship.<BR>
<BR>
Right now, I could do this:<BR>
<BR>
Vendor->has_many(crossovers=>['Vendor::Crossover'=>'VNDRID']);<BR>
<BR>
and<BR>
<BR>
Vendor::Crossover->has_many(contacts=>['Vendor::Contact'=>'CTCTID']);<BR>
<BR>
but I want the crossover table to be automatically populated just by editing/adding the Vendor::Contact and Vendor records.<BR>
<BR>
Your example would work fine otherwise. Thank you.<BR>
<BR>
d. Taylor Singletary<BR>
<BR>
On Wed, 2005-03-02 at 21:01 +0000, William Ross wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">The other options mentioned here will no doubt offer more, but your </FONT>
<FONT COLOR="#000000">immediate need is more easily met like this:</FONT>
<FONT COLOR="#000000"> Vendor->has_many(contacts => [ 'Vendor::Contact' => 'CTCTID' ]);</FONT>
<FONT COLOR="#000000">It's in the Class::DBI docs under relationships/has_many/mapping. I </FONT>
<FONT COLOR="#000000">think you still need to have a Vendor::Contact package in your tree, </FONT>
<FONT COLOR="#000000">but you don't have to worry about its relationships or even columns </FONT>
<FONT COLOR="#000000">unless you decide to start holding more information there.</FONT>
<FONT COLOR="#000000">best</FONT>
<FONT COLOR="#000000">will</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> Is it possible with Class::DBI to semi-transparently manage the </FONT>
<FONT COLOR="#000000">> crossover tables and still assert relationships like Vendor::Contact, </FONT>
<FONT COLOR="#000000">> Customer::Contact? How is that done? When accessing these objects I </FONT>
<FONT COLOR="#000000">> don't want to have to think about maintaining the relationships in the </FONT>
<FONT COLOR="#000000">> crossover tables at all. Customers can have many contacts, Vendors can </FONT>
<FONT COLOR="#000000">> have many contacts.</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> Thanks for a push in the right direction on this.</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> d. Taylor Singletary </FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-og20eCVosFAkrxqNUQVj--