I need the following sql query converting to Propel:
SELECT tag.tag, count( content_tag.tag_id ) AS weight
FROM content_tag, tag
WHERE content_tag.tag_id = tag.id
GROUP BY content_tag.tag_id
ORDER BY weight DESC , tag.ord_id ASC
Any ideas on how to d开发者_开发知识库o the count clause?
Thank you
$c = new Criteria();
$c->addJoin(ContentTagPeer::TAG_ID,TagPeer::ID,Criteria::INNER_JOIN);
$c->add(ContentTagPeer::TAG_ID, 'Count(' . ContentTagPeer::TAG_ID . ') AS Weight' , Criteria::CUSTOM);
$c->addGroupByColumn(ContentTagPeer::TAG_ID);
$c->addAscendingOrderByColumn(TagPeer::ORD_ID);
$c->addDescendingOrderByColumn('Weight');
I think that could help solve it
精彩评论