I'm doing a function using the PDO, when I try to use the PREPARE method the function does not finish successfully, it replaces PREPARE with QUERY by changing some arguments and it worked.
But my question is the following because what with PREPARE is not working?
function create($tabela, array $dados){
$campos = implode(", ", array_keys($dados));
$values = "'".implode("', '", array_values($dados))."'";
$pdo = new PDO('mysql:host=localhost;dbname=curso','root','');
try{
$operacao = $pdo->prepare("INSERT INTO $tabela (?) VALUES (?)");
$operacao->bindValue(1,$campos);
$operacao->bindValue(1,$values);
$operacao->execute();
}catch(PDOException $e){
echo 'Erro '.$e->getMessage();
}
if($operacao->rowCount()>0){
return true;
}else{
echo "Não Cadastrou";
}
};
$evento = array('id_cliente' => 81, 'nome_cliente' => 'Marcos', 'idade' => 32);
create('clientes',$evento);