I have the following in mySQL:
SELECT t.tag, COUNT( * ) AS `count`
FROM tag t, content_item_tag c
WHERE t.id = c.tag_id
GROUP BY t.id, c.tag_id
ORDER BY count DESC
LIMIT 0 , 30
Can someone help me convert this to a Criteria() query in Propel?
Thanks
See the latest entry on Propel’s blog: How Can I Write This Query Using An ORM? The following is a quote from there:
Answer #1: You Don’t Need An ORM
A recent post on the propel-users mailing list asked for the Propel version of the following query:
This query is not object-oriented, it’s purely relational, so it doesn’t need an Object-Relational Mapping. The best way to execute this query inside an ORM is to skip the ORM and use PDO directly:
Hints of a purely relational query are:
That’s the most common answer to the “How Can I Write…” question. It is not a bad thing to resort to a direct database query inside a project using an ORM when it’s the right tool for the job. If Propel makes the code much more complex to write, not reusable, or painfully slow, then don’t use it. Be pragmatic.