We have a table for articles, and a table for locale data for articles.
class Article_Model extends ORM {
protected $has_many = array('article_translations');
[…]
class Article_Translation_Model extends ORM {
[…]
‘articles_translations’ table contain ‘article_id’, ‘locale_id’, ‘heading’, ‘body’, etc. columns.
Is it possible to do
SELECT article.id, article_translations.heading, article_translations.body
FROM articles
JOIN articles_translations ON (articles_translations.article_id = article.id)
WHERE articles_translations.locale_id = 'en_US.UTF-8'
using Kohana 2 ORM?
The ->with() construction works only for has_one relations. The articles_translations.article_id and articles_translations.locale_id is UNIQUE, of course.
You could go the other way though:
Then you can reference the article columns as: