Reputation: 6907
I have my models setup as a many-to-many using through
with a pivot table. However, I would like to add some extra data into the pivot table.
In the past (kohana 3.0
) I was able to provide extra data with the add method
$obj->add('alias', $related, array('extra'=>'data'))
But its seems in Kohana 3.3 that the add
method does not provide the third parameter for extra data, and I cannot seem to find how to do this short of after saving, adding more data then re-saving.
Upvotes: 0
Views: 350
Reputation: 506
This isn't supported anymore since Kohana 3.1
.
The reason they removed it (Source: http://dev.kohanaframework.org/issues/3754):
We decided to remove this because it's better to use a through model if you need to put data in your pivot table. Inserting the data directly in the add() method bypasses validation and filtering that would normally be in your model. Use a model if you need data in your through table. We won't be changing this.
You now have to make a model for the pivot table and place the additional information in that model.
Then instead of using has_many "through" (n:n)
you should use has_many (1:n)
relationship for both tables to the pivot table.
I hope this answers your question.
Upvotes: 2