CodeIgniter Forums
DataMapper Join Table with extra fields - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Libraries & Helpers (
+--- Thread: DataMapper Join Table with extra fields (/thread-48105.html)

DataMapper Join Table with extra fields - El Forum - 01-04-2012


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!