I set up an many to many relationship between Orders and Sets. An Order can contain many Sets and different Sets can belong to different Orders. Because you can set the amount for a set in a order there should be an additional column for amount. So e.g. an Order can consist of 5 x "Set A" and 10 x "Set B".
This is the schema of the join table:
OrderSet:columns:
amount: integer
order_id:
type: integer
primary: true
set_id:
type: integer
primary: true
Works fine so far, I just don“t know how I can set the value of the amount column.
This is how I save the order / set-order relationship:
public function saveOrder($data){
$tempSets = $data->sets;
$order = new Order();
unset($data->sets);
$order->merge((array) $data);
foreach($tempSets as $set){
$q = Doctrine_Query::create()
->from('Set s')
->where('s.id = ?', $set->id);
$set = $q->fetchOne();
$order->sets->add($set);
}
$order->save();
}
How can I set the amount of each set?
Many to many thanx for your help. cheers, Florian