Feature Request #3754
ORM add 3 pram $data
|Assignee:||Isaiah DeRose-Wilson||% Done:|
|Target version:||Kohana v3.x - v3.1.1|
The function add in KO 3.1 Modul ORM: add($alias, $far_keys) was change.
Plz insert the 3 param $data like KO 3.0.9 add($alias, ORM $model, $data = NULL)
#1 Updated by Isaiah DeRose-Wilson over 3 years ago
- Status changed from New to Closed
- Assignee set to Isaiah DeRose-Wilson
- % Done changed from 0 to 100
- Resolution set to wontfix
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.
#4 Updated by Peter Briers about 3 years ago
Okay, so what I found on Github:
removing $data parameter from ORM::add(), this breaks the idea of models validating their own data.
If your pivot table has data in it, it is technically not a 'pivot' table.
The proper way to use these tables is to create 3 models and use one-to-many relationships on both ends.
The middle table should validate itself, and will give you a way to access that extra data._
It may 'technically' not be pivot-table, but most people see them that way!
Now you have to do a LOT more coding, instead just having one beautiful line of code. :(
I also see it'll be harder to implement again, because you guys made the parameter $far_keys accept 3 kinds of different objects: an integer (id), a model (orm), or an array of integers (id's).
So on one hand, you make something that should be easy hard by making conventions more strict.
On the other hand, you make something that already was easy more loose (giving an array of IDs). You could just use a simple loop. (but that probably would get more queries)
Please reconsider this?!