Re: HABTM-Linking multiple times to the same model
hi, accidentaly I came across this, which might help you with your problem: http://www.webiscake.com/model-x-with-multiple-associations-leading-to-model-y/ the code is: array('className' => 'User', 'foreignKey' => 'sender_id' ), //Same goes for Receiver 'Receiver' => array('className' => 'User', 'foreignKey' => 'receiver_id' ), ); } ?> if anyone with real expertise could confirm that would be great. and hi all, btw. good luck! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
HABTM-Linking multiple times to the same model
Hello everybody! I would like to link one Model to another by HABTM-joinTables. That is no problem as long as I link Model A to Model B one time. But how do I link Model A to Model B for different uses. I try to explain by an example: I have a "Shop" (Model A) and I have a "Person" (Model B) I want to link multiple Persons to a Shop for different uses. 1.) Persons that do buy in this shop (joinTable jobs_persons) 2.) Persons that do want a newsletter from the shop (a second joinTable newsletter_persons_shops) The first variant is discussed everywhere. I tried the following: class Shop extends AppModel { ... var $hasAndBelongsToMany =array( 'Person' => array( 'className' => 'Person', 'joinTable' => 'persons_shops', 'foreignKey' => 'shop_id', 'associationForeignKey'=> 'person_id', 'conditions' => '', 'order' => '', 'limit' => '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ), 'NewsletterPerson' => array( 'className' => 'Person', 'joinTable' => 'newsletter_persons_shops', 'foreignKey' => 'shop_id', 'associationForeignKey'=> 'person_id', 'conditions' => '', 'order' => '', 'limit' => '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ), ); } On reading the data of the Shop this seems to work. But is this the right way to do it? And how do I define the Linking in the "Person"-Model? var $hasAndBelongsToMany = array( 'Shop' => array( 'className' => 'Shop', 'joinTable' => 'persons_shops', 'foreignKey' => 'person_id', 'associationForeignKey'=> 'shop_id', 'conditions' => '', 'order' => '', 'limit' => '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ), ... ??? ... I hope anybody understands my question :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HABTM-Linking multiple times to the same model
Damn, the first part has an error. I meant this... class Shop extends AppModel { ... var $hasAndBelongsToMany =array( 'Person' => array( 'className' => 'Person', 'joinTable' => 'persons_shops', 'foreignKey' => 'shop_id', 'associationForeignKey'=> 'person_id', 'conditions' => '', 'order' => '', 'limit' => '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ), 'NewsletterPerson' => array( 'className' => 'Person', 'joinTable' => 'newsletter_persons_shops', 'foreignKey' => 'shop_id', 'associationForeignKey'=> 'person_id', 'conditions' => '', 'order' => '', 'limit' => '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ), ); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
HABTM-Linking multiple times to the same model
Hello everybody! I would like to link one Model to another by HABTM-joinTables. That is no problem as long as I link Model A to Model B one time. But how do I link Model A to Model B for different uses. I try to explain by an example: I have a "Shop" (Model A) and I have a "Person" (Model B) I want to link multiple Persons to a Shop for different uses. 1.) Persons that do buy in this shop (joinTable jobs_persons) 2.) Persons that do want a newsletter from the shop (a second joinTable newsletter_persons_shops) The first variant is discussed everywhere. I tried the following: class Shop extends AppModel { ... var $hasAndBelongsToMany =array( 'Person' => array( 'className' => 'Person', 'joinTable' => 'persons_shops', 'foreignKey' => 'shop_id', 'associationForeignKey'=> 'person_id', 'conditions' => '', 'order' => '', 'limit' => '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ), 'NewsletterPerson' => array( 'className' => 'Person', 'joinTable' => 'admin_extensions_devices', 'foreignKey' => 'shop_id', 'associationForeignKey'=> 'person_id', 'conditions' => '', 'order' => '', 'limit' => '', 'unique' => true, 'finderQuery' => '', 'deleteQuery' => '', ), ); } On reading the data of the Shop this seems to work. But is this the right way to do it? And how do I define the Linking in the "Person"-Model? var $hasAndBelongsToMany = array( 'Shop' => array( 'className' => 'Shop', 'joinTable' => 'persons_shops', 'foreignKey' => 'person_id', 'associationForeignKey'=> 'shop_id', 'conditions' => '', 'order' => '', 'limit' => '',