N
N
Nubbin2019-05-02 14:15:06
Laravel
Nubbin, 2019-05-02 14:15:06

Case sensitive in Laravel?

Good afternoon, how to get data from the database case sensitive.
Example:

$m = $test->where('name', 's1')->first(); // Результат: $m->id (1)
$m = $test->where('name', 'S1')->first(); // Результат: $m->id (5)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-05-02
@Nubbin

collate at the base/field. If you need this everywhere for this field, make the field utf8mb4_cs instead of utf8mb4_ci. The second option is to change where, like so:
->whereRaw("BINARY `name`= ?",[$name])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question