5
I have a system where I use the Laravel
to make the query in the database. It 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, how do I use the LIKE
to query by name, if the user adds to the query %
(percentage sign), it brings all the data, since it is a special character of the %
.
How do I escape the percentage character in MYSQL?
Note: I just added the tag php
and mysql
. The Laravel
in this case it is only the tool I am using, but the solution can serve indelibly from I use it or not.
What is wrong with my question? What can be improved?
– Wallace Maxters
http://answall.com/q/87474/91 :D
– rray
@rray I had already asked and forgot! kkkkk. Duplicated, Ué.
– Wallace Maxters
I can’t say ... the context seems different.
– rray
The escape functions of both PDO and mysqli already escape this type of character. I don’t know how the Laravel works with it.
– Bacco