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

  • Home
  • SEARCH
  • 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 6659503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:02:33+00:00 2026-05-26T02:02:33+00:00

id | name 1 | aaa 2 | bbb 3 | ccc 4 |

  • 0
id  | name 
1   | aaa  
2   | bbb  
3   | ccc  
4   | ccc  
5   | aaa  
6   | ccc  
7   | ccc  
8   | aaa  
9   | bbb  
10  | ccc  
11  | aaa

i would like become:

name | count
ccc  | 5
aaa  | 4
bbb  | 2

orderby count DESC

i made:

public function getCount() 
{        
        $q = $this->createQuery('q')
            ->select('*')
            ->addSelect('count(q.name) as count')
            ->groupBy('q.name')
            ->orderBy('count DESC');

        return $q->execute();        
}

but if :

foreach ($count as $c) {
  echo $c;
}

this show me only first data in table.

how can i make it?

  • 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-26T02:02:33+00:00Added an answer on May 26, 2026 at 2:02 am

    Change your loop to this:

    foreach ($count as $c) {
      echo $c->count . "\n";
    }
    

    edit:
    a good way to debug this is to change your return to

    $q->fetchArray();
    

    and then in your loop

    print_r($c);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV file with lines like this: AAA,A-name,num1,num2,num3 BBB,B-name,num1,num2,num3 CCC.DDD,C-name,num1,num2,num3 EEE.FFF.GGGG,E-name,num1,num2,num3 HHH.H-name,num1,num2,num3
Hi assume that I have a JSON like this: var myJson = [{id:111,name:aaa,surname:bbb}, {id:222,name:ccc,surname:ddd}]
I have a datatable select like: productData.Select(Name = 'AAA BBB # CCC'); I know
My json output look like [{id:2,name:AAA},{id:1,name:BBB}]. I want to parse this using Qjson in
I have table: name marks aaa 100 aaa 56 aaa 120 bbb 56 bbb
Two tables: table1 id | name 1 | aaa 2 | bbb 3 |
Suppose the module AAA::BBB::CCC located in ~/modules/AAA/BBB/CCC.pm , and ~/modules is in @INC ,
I have several INPUTs: <input type=text name=entry[1] value=aaa id=firstEntry /> <input type=text name=entry[2] value=bbb
var name = 'Mike'; var person = { name: 'John', welcome: function(){ var name
SELECT name FROM sys.databases -- this can list all database name in the server

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.