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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:52:36+00:00 2026-06-16T22:52:36+00:00

When trying to sort data using the CakePHP Paginator, it is returning case-sensitive sort

  • 0

When trying to sort data using the CakePHP Paginator, it is returning case-sensitive sort results. I have tried adding UPPER around the field I specify in the order query, but that doesn’t seem to be working. I’m using CakePHP 2.0.3 with a PostgreSQL database. My $paginate variable and the code to call it are:

var $paginate = array(
    'limit' => 25,
    'order' => array(
        'User.first_name' => 'asc'
    )
);
..

(In my view function)
    $users = $this->paginate('User');

How can I force CakePHP to return a case-insensitive sort result?

  • 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-16T22:52:37+00:00Added an answer on June 16, 2026 at 10:52 pm

    It is a shame that you can’t use something like this:

     'UPPER(User.first_name)' => 'ASC'
    

    Which would be fairly basic.

    I had this issue in a project, whereby I replaced the ‘order’ array with something like this:

    'order' = "UPPER(first_name) ASC"
    

    which successfully gave me the correct output.

    Unfortunately, however, clicking the column header fields to sort my paginated table then replicated the issue, whereby my names were once again case-sensitive.

    The solution that I came up with was to modify the PaginatorComponent of cakephp itself, so that my sort order would always be correct.

    In the PaginatorComponent (/lib/Cake/Controller/Component/PaginatorComponent.php) I modified the validateSort function, replacing the following line:

    $options['order'] = $order;
    

    With the four lines below:

    foreach($order as $order_field=>$order_direction){
        $neworder['UPPER('.$order_field.')'] = $order_direction;
    }
    $options['order'] = $neworder;
    

    It’s not elegant, and is essentially just forcing the ‘UPPER()’ around the field name.

    This worked in my particular situation whereby I need to always have case-insensitive queries.

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

Sidebar

Related Questions

I am using cakePHP 1.26. I am trying to sort the data by Date
I have a data-bound DataGridView that I am trying to sort using an IComparer.
I am trying to sort data which is from Generic List object. By using
I am using celltable of GWT. And I am trying to sort a data
I am trying to sort an array. I have an array of data, where
I'm using NHibernate as my ORM and I'm trying to sort some data. The
I am trying to sort data by using the GROUP BY function. My query
I'm trying to Sort (with.sort) the data (entirerow) using .setrange. However the Dynamic range
I do not have any idea on how to sort data using datagridview in
I am using ArcGIS. I am trying to sort the data manually after its

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.