fairly simple question I think that I couldn’t find the answer to in the docs (http://kohanaframework.org/guide/orm/relationships)
I have the need to define relationships with several Models (in bold) (each has a corresponding table) at once, if that makes sense.
I have several models that have slightly intertwined relationships.
the connection model $_belongs_to the user. This code works fine, great. But the connection also needs to $_has_one song (i can haz cheezeburger??), and to $has_one keyword, if that makes sense.
This is because I want to access the song name and keyword name through the connection, for instance using $connection->song->name, and then $connection->keyword->name…
SO, the problem is I can’t seem to chain the relationships detailed above, as I can only declare one relationship per model…. so how do I do this? Or maybe there’s another much easier way of doing it that I’m unaware of…
I presume I’m being a n00b and would love some help on this. Cheers.
You can collect relationships in arrays:
PS. But it seems like both
songandkeywordmust be in a$_belongs_toproperty (onesonghas manyconnections, oneconnectionbelongs tosong).