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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:53:13+00:00 2026-06-14T12:53:13+00:00

When paginating my user model in CakePHP, I can sort by some values, but

  • 0

When paginating my user model in CakePHP, I can sort by some values, but not others. I can order the results by created or email fine, for example, but ordering by username or reputation comes back with a list of users in a seemingly arbitrary order. So for instance:

$this->paginate = array('conditions' => array('User.is_active' => true), 'limit' => 24, 'order' => array('User.created' => 'DESC'));

works as expected, but

$this->paginate = array('conditions' => array('User.is_active' => true), 'limit' => 24, 'order' => array('User.reputation' => 'DESC'));

doesn’t.

I thought at first this might be a database issue, but when I search the database directly everything is returned and sorted as expected.

Note: I’m using MongoDB with ichikaway’s MongoDB plugin for CakePHP; paginating users used to work fine, so I’m positive it’s not a bug with the plugin, but something has changed somewhere and I can’t pinpoint what.

Finally, when I view the queries in the debug info, I can see that CakePHP isn’t even passing the order value to the database when searching. The first search above displays this:

db.users.find( {"is_active":true}, [] ).sort( {"created":-1} ).limit( 24 ).skip( 0 )

and the second this:

db.users.find( {"is_active":true}, [] ).sort( [] ).limit( 24 ).skip( 0 )

Why is CakePHP letting me order by some things, but not others?

  • 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-14T12:53:14+00:00Added an answer on June 14, 2026 at 12:53 pm

    Oops. It was a database error; somehow, a record got created with only a few of the fields in it (e.g., _id, created, modified, and a few others), which not coincidentally were the only ones that I could sort by. Deleting it got everything back to normal.

    Strange that doing a search would work fine, but paginating with the same parameters wouldn’t. Maybe it is a plugin/Cake bug after all?

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

Sidebar

Related Questions

My rails project is paginating the HTML format but not the the others. Can
Similar to this question — but due to my ineptitude with CakePHP, I can't
I am using will_paginate for paginating my results. Most of my site is AJAXified.
I have a rails 3 app that displays user submissions in order of how
I want to have cakephp paginate data and still use containable , but for
I've got a User model. The app has registered users and registered artists. A
When paginating through our Phrase table it takes very long to return the results.
I am using running a simple find all and paginating with willpaginate, but I'd
I'm trying to do some pagination when user scrolls to the bottom of the
I'm trying create pagination on my page. The user can select the number of

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.