开发者

mysql to Propel

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜