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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:48:35+00:00 2026-06-13T11:48:35+00:00

When paginating results that use GROUP BY in CakePHP, the # of results count

  • 0

When paginating results that use GROUP BY in CakePHP, the # of results count is incorrect. This is a documented item as is (was) to be expected, but according to this page in the CakePHP book:

In CakePHP 2.0, you no longer need to implement paginateCount() when
using group clauses. The core find(‘count’) will correctly count the
total number of rows.

I’m using CakePHP 2.2.3, yet I still have the problem. Is there something specific I need to do? Am I misreading the statement? Do I still need to use custom paginate() and/or paginateCount methods?

Clarification of “incorrect count”: I’m joining table1 w/ table2 – so even though I only have one “table1 item”, it retrieves 2 rows… but then I group by to the id of the table1 item, which makes it return only 1 item. The count, however, shows “2 found”, but only displays 1 item.

Update: (code)

$this->Paginator->settings = array(
'limit' => (int) 20,
'conditions' => array(
    (int) 0 => array(
        'Article.node_type_id' => '5050ede8-3f88-45f4-b58f-1130d9d84497'
    ),
    (int) 1 => array(
        'OR' => array(
            'DataText.title LIKE' => '%john%',
            'Article.name LIKE' => '%john%'
        )
    )
),
'order' => array(
    'Article.created' => 'DESC'
),
'fields' => array(),
'joins' => array(
    (int) 0 => array(
        'table' => 'data_texts',
        'alias' => 'DataText',
        'type' => 'INNER',
        'conditions' => array(
            (int) 0 => 'DataText.node_id = Article.id'
        )
    )
),
'contain' => array(
    'Slug' => array(
        'order' => array(
            (int) 0 => 'FIELD(Slug.language_id, "c141eafd-567a-4bc5-badd-c5a163c01f46") DESC'
        )
    ),
    'NodeType' => array(
        'ChildNodeType' => array()
    ),
    'DataLocation' => array(
        'conditions' => array()
    ),
    'DataMeta' => array(
        'conditions' => array()
    )
),
'group' => 'Article.id'

)

Paginate call itself:

$nodes = $this->paginate($model);
  • 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-13T11:48:36+00:00Added an answer on June 13, 2026 at 11:48 am

    There was a bug in find("count") and it returned incorrect count if the query resulted in records for only 1 group. This has been fixed now. The fix was probably done after 2.2.3 release so just use the master branch from github for now and the fix will be available in the next release.

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

Sidebar

Related Questions

I have a php page that also has another php page inside it, this
I'm working on a problem that requires caching paginated search results: Paginating very large
I've tried to use this tutorial Kaminari endless page and also watched Ryan Bates
My rails project is paginating the HTML format but not the the others. Can
I'm paginating a list of items, and currently the page listed on page load
This is my pagination script which extracts info for my TV guide project that
I'm creating a page that's a search result... When you're viewing one of the
I was trying to use django-endless-pagination twitter pagination , but Django is throwing and
I am trying to paginate the results of an SQL query for use on
I have a pagination function that I use for my database search that limits

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.