0
// Mysqli
$vf = mysql_query('SELECT id, cnpj, id_erp, fantasia, razao FROM usuarios WHERE nivel="3" AND
(
nome LIKE "%' . limpa($_POST['termo']) . '%" OR
email LIKE "%' . limpa($_POST['termo']) . '%" OR
) ORDER BY nome ASC');
//Conversão para PDO:
$vf = $conn->prepare('SELECT id, cnpj, id_erp, fantasia, razao FROM usuarios WHERE nivel=:nivel AND ( nome LIKE :nome OR email LIKE :email ) ORDER BY nome ASC');
$vf->execute(array(
'nivel' => "3",
'%nome%' => limpa($_POST['termo']),
'%email%' => limpa($_POST['termo']),
));
I wonder if the % filter is passed in the array or in the query itself, in PDO...
$vf->execute(array(
'nivel' => "3",
'nome' => %limpa($_POST['termo'])%,
'email' => %limpa($_POST['termo'])%,
));
Or would it be like above?
If I understand your doubt, you pass the
%
as part of the variable in the query. For example:'%'.limpa($_POST['termo']).'%'
or'%teste%'
.– Weslley Araújo