I have a system where I use Laravel
to query the database. This is a search form.
I use the following code:
$search = trim(Input::get('search'));
return Empresa::where('nome_fantasia', 'LIKE', $search)->get();
The problem is that, since I use LIKE
to query by name, if the user adds in the %
(percent sign) search, it returns all the data since it is a character special of %
.
How do I escape the percentage character in MYSQL?
Note : I've just added the tag php
and mysql
. The Laravel
in this case is just the tool I'm using, but the solution can serve indepently of whether I use it or not.