[Solar-talk] _hasOne Help

Kilbride, James P. James.Kilbride at gd-ais.com
Wed Nov 14 12:12:44 CST 2007


What's the name of the column going to be? if it's going to called
market Id I'd think you have to do that rather than simply id because
otherwise it's going to think that the company id column(called id on
company) is actually a foreign key to the market. 
 
This is why I don't really like solar's assumption that there is an ID
column on all tables since I like to have the primary key Id called even
on it's native table by the id type rather than simply id. It's purely a
'preference' thing but I tend to have my market tables, for example,
have Market_Id as the primary key and company has Company_Id, so the
names have an easy to see equivalence relationship when they end up
foreign keyed in other tables.
 
James Kilbride

________________________________

From: solar-talk-bounces at lists.solarphp.com
[mailto:solar-talk-bounces at lists.solarphp.com] On Behalf Of Raymond
Kolbe
Sent: Wednesday, November 14, 2007 12:57 PM
To: solar-talk at lists.solarphp.com
Subject: Re: [Solar-talk] _hasOne Help


For...

In COMPANY:

       $this->_hasOne('market', array(
           'foreign_class' => 'MARKET',
           'native_col'    => 'MARKET_id',
       )); 

In MARKET:

       $this->_belongsTo('company', array(
           'foreign_class' => 'COMPANY',
           'foreign_col'    => 'MARKET_id',
       )); 

Does  'native_col'    => 'MARKET_id',  does MARKET_id have to be the
name of the table col or, would I just keep the table col name 'id'?
This is the part that I think has really confused me when trying to
setup my DB and models. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20071114/9a6167f6/attachment.html


More information about the Solar-talk mailing list