Welcome Guest, Not a member yet? Register   Sign In
Save many to many relationship
#1

[eluser]chantheoun[/eluser]
Hi all,

I am a beginner. Here I would to ask all of you that how can I save many to many relationship in to the three tables(table A , table A-b , table B)? Now I am trying to save a new record with new ID into table A, and I have some IDs of table B that I want to save them to the middle table A-B depend on ID of table A. If anyone have experiences with this, please kindly share.
Example:

$a = new modelA();
$a->name = 'new name';
$a->des = 'something to say';

$b = new modelB();
$IDs = new array(1,2,3); //IDs of records in table B

$a->save(array($IDs=>$b));
#2

[eluser]WanWizard[/eluser]
Is this a Datamapper question?
#3

[eluser]chantheoun[/eluser]
Yes, I use datamapper ORM




Theme © iAndrew 2016 - Forum software by © MyBB