Marcin Sj Tue Nov 18 05:32:33 -0500 2014

Subject: has and belongs to many

I seems I can't really solve this issue with "has and belongs to many" relation. I got following tables:
articles: id
tags: id
articles_tags: id, tag_id, article_id

and models:

class ArticlesTag extends ActiveRecord\Model {
static $belongs_to=[['tag'], ['article']];
}

class Tag extends ActiveRecord\Model {
static $has_many=[
['articles', 'through' => 'articlestags'],
['articlestags']];
}

class Article extends ActiveRecord\Model {
static $has_many=[
['tags', 'through' => 'articlestags'],
['articlestags']];
}

I can fetch articles from a tag with $tag->articles, but not the other way round. $article->tags just keeps returing an empty array. What am I doing wrong?