を書く:トラブル私は私のデータベースの内容にタグを追加するプラグインを使用している、と私は次のクエリを書くことでいくつかの困難を抱えているDQLクエリ
私がタグ付けされたタグのリストが欲しいです少なくとも一つの公開されたコンテンツに、私が試した:
$this->tagsNumber = Doctrine_Core::getTable('Tag')
->createQuery('t')
->select('t.name, count(tg.tag_id) as nbr')
->innerJoin('t.Tagging tg')
->innerJoin('Content c on c.id = tg.taggable_id')
->where('c.state = ?', 3)
->orderBy('nbr DESC, t.name')
->groupBy('tg.tag_id')
->execute();
しかし、タグ付けとコンテンツとの関係は、プラグインで指定されていないので、Doctrineは「未知の関係の別名」例外がスローされます。
EDIT
私はPluginTagTable.class.phpで関数を使用してみました:
$q = Doctrine_Query::create()
->select('tg.tag_id, t.name, COUNT(tg.id) AS t_count')
->from('Tagging tg, tg.Tag t, Content c on tg.model_id = c.id')
->where('c.state_id = ?', 3);
$this->etiquettesOrdre = PluginTagTable::getAllTagNameWithCount($q,Array('model' => 'Content', 'sort_by_popularity' => true));
しかし、それはまだ数など、すべてのタグ、そして奇妙な数字を示しています。