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.
Try to change database collation. Maybe try utf8_bin Because in utf8_general_ci Š and S will be the same
You can alter the collation for a particular column by using the options
annotation in your entity (see the docs for database support):
class Brand
{
// ...
/**
* @ORM\Column(type="string", length=255, options={"collation":"latin1_general_ci"})
*/
private $name;
}
This will alter your database, so you'll have to create a migration or update the schema.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.