I’m building a application using Kohana 3.2 and Kohana ORM.
The application has systems. Systems contain components. A system may contain multiple components, but also multiple components of the same type. E.g. System_A may have 10 Component_Y and 3 Component_Z
So instead of just having two belongs_to fields in my pivot table I also want to store the count.
If I just use a has-many-through I won’t be able to access the count. Without ORM I’d just join the count onto the component in SQL, because the count is unique for the System + Component combination and so I can access the count for the component when I visit the object in the context of a certain system.
How best to go about this in Kohana ORM?
I solved it partially this way:
I’ve added the pivot tabel
systeemomvormerseparately tosysteem.I can now do this:
But it really still only is a partial solution, because I’m not able to
update()the result. Kohana says that the result is not loaded. However that’s outside the scope of this question and I’ll open a new question for that.This was also helpfull:
http://forum.kohanaframework.org/discussion/7247/kohana-3-orm-save-for-update-a-many-to-many/p1