I have Kohana ORM/Mysql query problem. I hope you can help.
To start of, here’s the diagram of tables:

Here’s my ORM definitions:
MEMBERS has many TOPICS through MEMBERS_TOPICS
ARTICLES has many TOPICS though ARTICLES_TOPICS
TOPICS has many MEMBERS though MEMBERS_TOPICS
TOPICS has many ARTICLES though ARTICLES_TOPICS
Think of it as a mailing list where you have members that has chosen topics of articles in which topics are also assigned to particular topics.
I couldn’t figure out how to make a single query so I can return joined results and send an email to individual members with articles they only chose through the topics they’ve chosen.
I hope to receive wisdom with mysql/kohana ninjas around. 😀
There is a
with()method in ORM that will join your tables, provided you have relations setup correctly in your models. Below a small example:Model:
View:
The relations are: