I have this code:
$whereBusca = "itaim-bibi";
$whereBusca = explode(',', $whereBusca);
$sql = $pdo->prepare('SELECT id, nome, caminho FROM regiao WHERE caminho IN (:whereBusca)');
$sql->execute(array("whereBusca" => "'".implode("','", $whereBusca)."'"));
$resultadoSql = $sql->fetchAll();
foreach ($resultadoSql as $valorSql) {
echo utf8_encode($valorSql['id']);
}
It works fine, but if the content of $ whereBusca is more than a region, it does not search, I do not know what I'm missing, look at the example of when it does not work:
$whereBusca = "itaim-bibi,jardins";
$whereBusca = explode(',', $whereBusca);
$sql = $pdo->prepare('SELECT id, nome, caminho FROM regiao WHERE caminho IN (:whereBusca)');
$sql->execute(array("whereBusca" => "'".implode("','", $whereBusca)."'"));
$resultadoSql = $sql->fetchAll();
foreach ($resultadoSql as $valorSql) {
echo utf8_encode($valorSql['id']);
}