? how to join models other than through id ?
hey everybody. i am kind of lost, with how cake wants me to deal with my problem. may be anybody here has some hints or suggestions for me? i want to associate two models through a different field than 'id'. i also want to have this relationship defined in the model itself, of course. the easiest way to describe the relationship would be like this: belongsTo/hasMany: modelA.modelB_field = modelB.field. where modelA belongsTo many modelB and modelB also has many modelA. but i dont think an extra join table is necassary but a simple join query would be enough in sql. thanx for the brainpower. \n --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ? how to join models other than through id ?
On 5/11/07, kzm [EMAIL PROTECTED] wrote: i want to associate two models through a different field than 'id'. i also want to have this relationship defined in the model itself, of course. #foreignKey: the name of the foreign key that points to the associated model. This is here in case you're working with a database that doesn't follow Cake's naming conventions. The above is a quote from somewhere very obvious - Figure out the obvious place and you will get the answer :) Cheers Tarique -- = PHP for E-Biz: http://sanisoft.com Cheesecake-Photoblog needs you!: http://cheesecake-photoblog.org = --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ? how to join models other than through id ?
On 11 mayo, 13:13, Dr. Tarique Sani [EMAIL PROTECTED] wrote: On 5/11/07, kzm [EMAIL PROTECTED] wrote: i want to associate two models through a different field than 'id'. i also want to have this relationship defined in the model itself, of course. #foreignKey: the name of the foreign key that points to the associated model. This is here in case you're working with a database that doesn't follow Cake's naming conventions. /me awaits the revelation that modelB.field isn't a primary key :D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ? how to join models other than through id ?
/me awaits the revelation that modelB.field isn't a primary key true. i tried to point out, that modelB.field is not primary or unique. its a value many modelB can share. so its not a n2m relationship but a m2m. modelA has many modelB and vice versa. their relationship is defined through the value of the field in modelB, which lots of modelB can share. i think in sql i would give an inner join a try but i try to avoid writing my query and try to generalize the relationship in the models itself, trying to use cake's infrastructure. \n --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ? how to join models other than through id ?
On 5/11/07, kzm [EMAIL PROTECTED] wrote: /me awaits the revelation that modelB.field isn't a primary key true. i tried to point out, that modelB.field is not primary or Tarique bows his head to Andy's insight into _ -- = PHP for E-Biz: http://sanisoft.com Cheesecake-Photoblog needs you!: http://cheesecake-photoblog.org = --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: ? how to join models other than through id ?
this is somehow the same: http://groups.google.com/group/cake-php/browse_thread/thread/c27ccc93a4a8f1d2 i dont know if anybody ever found a solution on this? (besides rewriting) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---