[Solar-talk] Der Models is On Fire

Kilbride, James P. James.Kilbride at gd-ais.com
Thu Oct 4 15:14:57 CDT 2007


Okay, ORM branch tracked down, installed. 

So now playing around to understand structures. Looking at Nodes I see
some interesting things. So let's say I have a database design that has
A and B. A has many B's and B has many A's(and in the DB I'd have a
A_B_Link table most likely). So would i do that using:

in Vendor_Model_A:

$this->_hasMany('Bs', array(
	'foreign_class' => 'B',
	'through'	         => 'A_B_Link',
	'through_key' => 'B_id',
));

in Vendor_Model_B:

$this->_hasMany('As', array(
	'foreign_class' => 'A',
	'through'	         => 'A_B_Link',
	'through_key' => 'A_id',
));

and then I'd need a class:

Vendor_Model_A_B_Link??

$this->_belongsTo('As', array(
	'foreign_class' => 'A',
	'foreign_key' => 'A_id',
));

$this->_belongsTo('Bs', array(
	'foreign_class' => 'B',
	'foreign_key' => 'B_id',
));

And how would, if I had the tables autocreated, force it to on the
A_B_Link table ONLY use A_id + B_id as the primary key? I mean there
isn't any reason for there to be a seperate ID for the A,B pair right?
Would I have to overload some of the solar classes to prevent this?

James Kilbride

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20071004/2aeac9af/attachment-0001.html


More information about the Solar-talk mailing list