Welcome Guest, Not a member yet? Register   Sign In
DataMapper Join Table with extra fields


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:
$recipe = new Recipe();
$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']);

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!

Theme © iAndrew 2016 - Forum software by © MyBB