开发者

mysql to Propel

开发者 https://www.devze.com 2023-01-31 23:38 出处:网络
I need the following sql query converting to Propel: SELECT tag.tag, count( content_tag.tag_id ) AS weight

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

精彩评论

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