PHP Laravel is one of the popular PHP frameworks. It has many inbuilt functions to reduce developers efforts while developing projects. To perform case sensitive search in laravel, there is no inbuilt function provided as of Laravel 5.6. So, now how we do it ?.
We have to use MySql function
So how we do in Laravel
We have to add
| user_table | |
| id | name |
|---|---|
| 1 | Eshin |
| 2 | Jozer |
| 3 | W3schools100 |
We have to use MySql function
BINARY in where clause to perform case sensitive querying. The MySql example is,
SELECT * FROM 'user_table' WHERE BINARY 'username' = 'W3schools100';
So how we do in Laravel
We have to add
DB::raw() raw query to make case sensitive query. For example
DB::table('user_table')->where(DB::raw("BINARY `username`"),'W3schools100')->get();
or
DB::table('user_table')->whereRaw("BINARY `username` = 'W3schools100'")->get();