Search code examples
phpsymfonydoctrine-ormdoctrinedoctrine-query

Doctrine - Order by utf-8 collation


Topic: ordering in doctrine.

I want to order car brands and the problem appears when I want to order brands that start with characters such as Š, Đ, Ć, Č or Ž. For example, when I use doctrines orderBy function I get this for my result:
Seat
Škoda
Suzuki.
Notice that Škoda is ordered like it starts with S and not Š.

Successful outcome:

How can I get data to be ordered according to Serbian latin alphabet so I get this result:
Seat
Suzuki
Škoda

Škoda would come after Suzuki cause Suzuki is last one that starts with S and Škoda is first that starts with Š, also Š comes after S in Serbian latin alphabet).

Or if this isn't possible is there any other solution where data wouldn't get mixed when ordered (Š not mixed with S, Č not mixed with C, Ć not mixed with C and so on)
Any help would appreciated.


Solution

  • Try to change database collation. Maybe try utf8_bin Because in utf8_general_ci Š and S will be the same