1
I’m having a hard time making an appointment SQL with the bindValue from PDO. I need to pass more than one value in the clause query like :cc plus the value returned is 0. If I use only one value the return is right.
if($dptoUser == "ADMINISTRACAO")
{
$centroDeCusto = "500";
}
if($dptoUser == "VENDAS")
{
$centroDeCusto = "100 OR bem.CENTRO_CUSTO LIKE 500 ";
}
$var2 = $rev_teste;
$sql = "SELECT count(bem.bem) as conte FROM AFX_BEM bem
LEFT JOIN AFX_BAIXA baixa
ON bem.BEM = baixa.BEM and bem.REVENDA = baixa.REVENDA and bem.AGREGADO =
baixa.AGREGADO
LEFT JOIN AFX_TRANSFERENCIA tr
on bem.BEM = tr.BEM and bem.REVENDA = tr.REVENDA and bem.AGREGADO = tr.AGREGADO
WHERE bem.revenda LIKE :contador AND bem.CENTRO_CUSTO LIKE :cc
AND baixa.BEM is null and baixa.REVENDA is null and baixa.AGREGADO is null and tr.BEM is null and tr.AGREGADO is null and tr.REVENDA is null ";
$result = $pdo->prepare($sql);
$result->bindValue(':contador', '%' . $var2 . '%', PDO::PARAM_STR);
$result->bindValue(':cc', '%' . $centroDeCusto . '%', PDO::PARAM_STR);
$result->execute();
$number_of_rows = $result->fetchColumn();
how can I make this consultation work?
vc can only bind values try to add a chunk of sql as value will not work, a value for each placeholders.
– rray
sorry my ignorance but could give me an idea of how I can do it?
– Fernando Fefu