I've got the two Models: Article and Hashtag with a HABTM relation. So in my database there are the tables articles (id,text,etc.), hashtags (id,value) and the join table articles_hashtags (article_id,hashtag_id). Now I want to find all articles with a given hashtag_id together with other conditions.. My attempt was first to find all articles with a given hashtag, to save them in an array:
$this->query("SELECT * FROM articles_hashtags WHERE hashtag_id=" . $hashtagId;");
and after that find articles with the other conditions,sorting etc in a second query like this:
$this->find('all', array('conditions' => array("Articles.id" => $articleIds),...
is it possible to find articles with a hashtag condition in one query?