Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3959748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:46:06+00:00 2026-05-20T02:46:06+00:00

I have the following in mySQL: SELECT t.tag, COUNT( * ) AS `count` FROM

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:46:07+00:00Added an answer on May 20, 2026 at 2:46 am

    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:

    SELECT COUNT(t1.user) AS users, t1.choice AS lft, t2.choice AS rgt
    FROM Choices t1 iNNER JOIN Choices t2 ON (t1.user = t2.user)
    WHERE t1.choice IN (...) AND t2.choice IN (...)
    GROUP BY t1.choice, t2.choice;
    

    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:

    <?php
    $con = Propel::getConnection();
    $query = 'SELECT COUNT(t1.user) AS users, t1.choice AS lft, t2.choice AS rgt
      FROM choice t1 iNNER JOIN choice t2 ON (t1.user = t2.user)
      WHERE t1.choice IN (?, ?) AND t2.choice IN (?, ?)
      GROUP BY t1.choice, t2.choice';
    $stmt = $con->prepare($query);
    $stmt->bindValue(1, 'foo');
    $stmt->bindValue(2, 'bar');
    $stmt->bindValue(3, 'baz');
    $stmt->bindValue(4, 'foz');
    $res = $stmt->execute();
    

    Hints of a purely relational query are:

    • The SELECT part cherry-picks some columns of the main table
    • The SELECT part aggregates data from several tables
    • The selected columns use vendor-specific SQL functions
    • The query joins tables through columns that don’t share a foreign key
    • The query is long and makes several joins
    • The query uses GROUP BY or HAVING
    • The user posts the query, but has no idea of the corresponding object model

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following MYSQL query: SELECT categories.key, categories.name, count(*) as itemsCount FROM categories
I have the following MySQL code: SELECT COUNT(e.eid) AS cnt, e.c_id, c.cdesc FROM e
I have following MySQL query: (SELECT c.Channel as name, count(*) as total_episode FROM (
I have the following table: mysql> SELECT * FROM `bright_promotion_earnings`; +----+----------+------------+----------+-------+ | id |
I have the following MySQL query: SELECT value_1, ( SELECT value_4 FROM table_1 WHERE
I have the following MySQL query: SELECT Project.*, `trk_deleted`, `trk_status`, `trk_state` FROM `project` AS
I have the following mysql query: EXPLAIN SELECT id, name, title, description, time FROM
I have the following MySQL query that I execute from a .php page SELECT
I have the following query in MySQL SELECT *,(select lat from node where id=node_id)as
I have a problem with the following MySQL query: SELECT * FROM TPDSessions WHERE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.