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 8238407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:48:12+00:00 2026-06-07T19:48:12+00:00

I have in my project old version (1.2) Propel. I would like make query:

  • 0

I have in my project old version (1.2) Propel. I would like make query:

SELECT city_id, COUNT(*) FROM House GROUP BY city_id

I tried:

  $c = new Criteria;
  $c->addAsColumn('count', 'Count(' . HousePeer::CITY_ID . ')'); 
  $this->results = HousePeer::doSelect($c);  

but this not working – return me only first record from database, without count etc.

i tried also:

$con = Propel::getConnection();
$sql = "SELECT city_id, COUNT(*) FROM House GROUP BY city_id";
$stmt = $con->createStatement();
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);
$this->results = HousePeer::populateObjects($rs);

but this throw me

Error populating House object [wrapped: Invalid resultset column: 3]

I would like only receive same as in SQL table:

city_id | count
1       | 2
2       | 4
3       | 3

etc

or get name City from CityPeer (i have correctly relations between City and House)
for example:

city       | count
New York   | 2
Paris      | 4
Washington | 3

but i can’t use this query in Propel.

  • 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-06-07T19:48:13+00:00Added an answer on June 7, 2026 at 7:48 pm

    You have a great example in the old snippet from symfony.

    Try:

    $c = new Criteria;
    $c->clearSelectColumns()->addSelectColumn(HousePeer::CITY_ID);
    $c->addGroupByColumn(HousePeer::CITY_ID);
    $c->addAsColumn('numCity', 'COUNT('.HousePeer::CITY_ID.')');
    $c->addJoin(HousePeer::CITY_ID, CityPeer::ID);
    
    $rs = HousePeer::doSelectRS($c);
    
    while ($rs->next())
    {
      // etc ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old Xcode project which contains a CoreData model (containing a version
I have a very old project that includes the source from another project directly,
I have copied a project from my old XP machine to my new Win7
I have an old project from the 1990's I desperately need to compile. The
I have an old project which i want to compile with the 4.1.2 version
I have a webservice project (old asmx technology) in which I have a class
I have an old project at our company that uses shell scripting a lot.
I have an old project that is mixed C and C++. It makes extensive
I have an old C++ project and I'm having problem building it. For a
I have an old c++ project compiled with VC6. I need to statically link

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.