Support the ongoing development of Laravel.io →
Database Eloquent

Hi. I perform $a = Items::where('code', '=', $code);

In the code column there are various entries, uniques and alphanumerics...

There are Asj7yd and Asj7yD As you see they are 2 DIFFERENT codes as the last letter is a d in first case and D in the second.

The count of the result of the query gives 2. WHYYYYYYY???

How do i make laravel CASE SENSITIVE for the queries it performs???

I need a global solution to implement and resolve this stupid problem. PLEASE HELP!

Last updated 3 years ago.
0

That's probably MySQL rather than Laravel

You'll need to write a raw SQL command like:

$a = Items::whereRaw("BINARY code  = '$code' ");
Last updated 3 years ago.
0

When I write my pure PHP code and perform queries i had never before met this problem. Maybe by luck. But how can i solve without putting this on every query? Can i change any MAIN LARAVEL FILE so that this happens ALWAYS by default???

Last updated 3 years ago.
0

I found a solution. In the config file, wher the mysql configuration I put utf8_bin instead of unicode_ci and reset migrations.

Now it performs the queries correctly

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

pcfun19 pcfun19 Joined 23 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.