php - Symfony 2 / Oracle Querybuilder result is case sensitive


I have a strange behavior with a query result in Symfony 2. I have data like this in an Oracle Database, in this exact order :

  1. BU 4 2015
  2. bU 2
  3. BU C
  4. BU S
  5. BU 4 2014

notice, the lower case in the second data

I Just want to display this list by alphabetical order, without any case sensitive support. The wanted result :

- BU C
- bU 2
- BU 4 2014
- BU 4 2015
- BU S

Now, here is the Querybuilder, made with Symfony 2.5.12 :

 $queryBuilder = $this->createQueryBuilder('e');

But the query, show my list in this order :

- BU C
- BU 4 2014
- BU 4 2015
- BU S
- bU 2
  • When i play the query displayed in symfony 2 profiler in my Oracle database client, i get the wanted result.

  • When i dump the query builder result, I get the wrong order list.

I manage to solve my problem by this

$queryBuilder = $this->createQueryBuilder('e');
    ->addSelect('UPPER( as HIDDEN name')

So, I just want to know why I get this strange behavior with the querybuilder ?





First of all, your "wanted result" is not actually in alphabetical order. A case-insensitive sort would yield the following order:

bU 2
BU 4 2014
BU 4 2015

Second of all, the way to do a case-insensitive sort with Oracle SQL is to useUPPER() orLOWER() on the column(s) you want to sort by, like so:


Finally, the way to do a case-insensitive sort with Doctrine QueryBuilder is exactly how you have done it: by addingUPPER( as HIDDEN name and then sorting by that field.

There is no strange behavior by QueryBuilder in this example.

People are also looking for solutions to the problem: How to insert php ajax textbox value into mysql database table?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.