0
I’m studying PHP and I’m seeing object oriented PDO but I realized a connection already tested, however the bindValue
returns error at time of execution, this error:
Fatal error: Uncaught Error: Call to Undefined method PDO::bindValue() in C: wamp64 www test class.php on line 27
Code:
<?php
class funcionario{
private $con;
private $nome;
private $cnpj;
public function __construct(){
require 'conexao.php';
$this->con = $pdo;
}
public function __set($atrib, $value){
$this->$atrib = $value;
}
public function __get($atrib){
return $this->$atrib;
}
public function cadastrarFuncionario(){
$cmd = $this->con;
$cmd->prepare("INSERT INTO fornecedor(nome, cnpj) VALUES (:nome, :cnpj");
$cmd->bindValue( ':nome', $this->nome );
$cmd->bindValue( ':cnpj', $this->cnpj );
$resultado = $cmd->execute();
if (resultado){
echo "Dados armazenados!";
}else{
echo "Dados Não Armazenados!";
}
}
}
?>
Actually the error is only the lack of a parenthesis at the end of the query. You need to close the VALUES parenthesis inside the quotes.
– Leonardo Furlan
had this Pdostatement error and had tmb this problem in query
– Geovane Silva