5
How to use the operator %
, to the bindValue()
, in query
down below:
$sql = 'SELECT * FROM nfe WHERE (cliente LIKE :cliente OR :cliente_ IS NULL)';
5
How to use the operator %
, to the bindValue()
, in query
down below:
$sql = 'SELECT * FROM nfe WHERE (cliente LIKE :cliente OR :cliente_ IS NULL)';
2
Your SQL
would be:
$sql = 'SELECT * FROM nfe WHERE (cliente LIKE :cliente OR cliente IS NULL)';
I might realize there’s a mistake.
Examples:
$stmt->bindValue(':cliente', $variavel."%", PDO::PARAM_STR);
or
$stmt->bindValue(':cliente', "$variavel%", PDO::PARAM_STR);
$stmt->bindValue(':cliente', "%".$variavel, PDO::PARAM_STR);
or
$stmt->bindValue(':cliente', "%$variavel", PDO::PARAM_STR);
$stmt->bindValue(':cliente', "%".$variavel."%", PDO::PARAM_STR);
or
$stmt->bindValue(':cliente', "%$variavel%", PDO::PARAM_STR);
References:
because my query would be 'SELECT * FROM nfe WHERE (cliente LIKE :cliente OR cliente IS NULL)';
? @Virgilionovic
if put a joint :cliente_
It’s kind of weird that it doesn’t work the way it is, what the purpose of it is?
@luccasrodrigo what is the purpose of your code, because, as I said many times is not necessary other times have need, only answers me in your current code was the way you wanted?
Yes, only now when you question me, cliente
and cliente_
with the same variables in the bind ends up generating redundancy... right?
According to @jlHertel, this redundancy exists and is a limitation of PDO, which does not allow having two parameters with the same name.
@luccasrodrigo Ok
Browser other questions tagged mysql pdo
You are not signed in. Login or sign up in order to post.
It worked @luccasrodrigo?
– novic
Yes, sorry for the delay (:
– lucasbento