• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DataMapper Join Table with extra fields

#1
[eluser]drakeonfire[/eluser]
Hello!

I'm trying to save relationships in a join table (Which is working woo!) but the problem is this join table has extra information, for example I have an Ingredients table and a Recipe table. the join table is ingredients_recipes and it contains:
id, ingredient_id, recipe_id, amount, unit_id

However when I try and save this, the amount and unit_id get left as 0 or NULL, even though I'm passing it the data. The bit where I'm doing this is:
Code:
$recipe = new Recipe();
$recipe->where('title',$title)->get();
$recipe_id = $recipe->id;
foreach($ing_rows AS $row) {
  $r = new Recipe($recipe_id);
  $r->amount = $row['amount'];
  $r->unit_id = $row['unit'];
  $i = new Ingredient($row['ing']);
  $r->save($i);
}

Any ideas? Sorry if this is a newb question, but from searching I couldn't find anything of help, or from the guide book.

Thank you!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.