Issue
I have many to many relationship and in the MYSQL database I have an associative table for them, now do I need a model for that table or it's just enough to declare it in the relation()
function
public function relations()
{
return array(
'store'=>array(self::MANY_MANY, 'store',
'medinventory(MedID_FK, StoreID_FK)'));
}
Solution
You don't need a model for the intermediate table if you are only using it for the mapping.
You would need a model in case this table holds other attributes that need to be accessed.
for example considering your many to many relationship between store and inventory.
If you need to add an attribute to the medinventory table, to tell the application when was the relation created (created_time), and later on you need to access that property, then yes, would need to create a model.
Answered By - Asgaroth
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.