Re: Question on how to implement Class::DBI with crossover tables..

[prev] [thread] [next] [Date index for 2005/03/02]

From: d. Taylor Singletary
Subject: Re: Question on how to implement Class::DBI with crossover tables..
Date: 21:23 on 02 Mar 2005
--=-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-&gt;has_many(crossovers=&gt;['Vendor::Crossover'=&gt;'VNDRID']);<BR>
<BR>
and<BR>
<BR>
Vendor::Crossover-&gt;has_many(contacts=&gt;['Vendor::Contact'=&gt;'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-&gt;has_many(contacts =&gt; [ 'Vendor::Contact' =&gt; '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">&gt;</FONT>
<FONT COLOR="#000000">&gt;  Is it possible with Class::DBI to semi-transparently manage the </FONT>
<FONT COLOR="#000000">&gt; crossover tables and still assert relationships like Vendor::Contact, </FONT>
<FONT COLOR="#000000">&gt; Customer::Contact? How is that done? When accessing these objects I </FONT>
<FONT COLOR="#000000">&gt; don't want to have to think about maintaining the relationships in the </FONT>
<FONT COLOR="#000000">&gt; crossover tables at all. Customers can have many contacts, Vendors can </FONT>
<FONT COLOR="#000000">&gt; have many contacts.</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt;  Thanks for a push in the right direction on this.</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt;  d. Taylor Singletary </FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-og20eCVosFAkrxqNUQVj--

Re: Question on how to implement Class::DBI with crossover tables..
d. Taylor Singletary 21:23 on 02 Mar 2005

Creation of composite objects automatically
Peter Speltz 22:32 on 02 Mar 2005

Generated at 00:32 on 04 Mar 2005 by mariachi v0.52