3
Good afternoon, Guys, I’m studying the PDO and with the following difficulty, the query runs (or rather, does not return me any error), only when I go to the bank has nothing, what I do?
 pdo = new PDO ("mysql:host=localhost; dbname=clientes;","root","");
       } catch (PDOException $erro){
           echo "Não Foi possivel conectar ao Banco: ".$erro->getMessage();
       }
   }
   public function cadastrar($nome, $email, $cpf, $data_nascimento, $telefone, $endereco, $data_do_cadastro){
              //Checa se já há algum CPF igual no banco
              $checa_cpf =  $this-> pdo -> prepare ("select CPF from cliente where CPF = :cpf");
              $checa_cpf -> bindParam (':cpf', $cpf);
              $checa_cpf -> execute();
               if ($checa_cpf -> rowCount() >= 1){
                   echo "Cadastro já existente.";
               } else {
                try{
                   $insert = $this-> pdo ->prepare("INSERT INTO clientes(nome, cpf, email, data_nascimento, telefone, endereco, data_do_cadastro )
                   values (':nome',':cpf' ,':email',':data_nascimento', ':telefone',':endereco', ':data_do_cadastro')");
                   $insert -> bindParam(':nome', $nome);
                   $insert -> bindParam (':cpf', $cpf);
                   $insert -> bindParam (':email', $email);
                   $insert -> bindParam (':data_nascimento', $data_nascimento);
                   $insert -> bindParam (':telefone', $telefone);
                   $insert -> bindParam (':endereco', $endereco);
                   $insert -> bindParam (':data_do_cadastro', $data_do_cadastro = date ('d-m-Y'));
                   $insert -> execute();
              }catch (PDOException $erro){
                      echo "Não foi possivel inserir os dados no banco: ".$erro->getMessage();
              }
        }
   }
   public function apagarCadastro($cpf){
           //Executa uma query que apaga os dados o banco
    try{
           $stmt = $this-> pdo -> prepare("DELETE FROM CLIENTE WHERE CPF = ':cpf' ");
           $stmt-> bindParam (':cpf', $cpf);
           $stmt -> execute();
    }
    catch (PDOException $erro) {
           echo "Não foi possivel apagar os dados: ". $erro->getMessage();
    }
    if ($this -> pdo -> rowcount() >=1 ){
           echo "Todos os dados foram apagados com Sucesso.";
       }
   }
   public function atualizarNome($newNome, $oldNome){
           //Executa uma query que atualiza o nome no banco
           try {
           $this -> pdo -> prepare ("UPDATE CLIENTES SET NOME = ':nome' WHERE NOME = ':nome2'");
           $this -> pdo -> bindParam (':nome', $newNome);
           $this -> pdo -> bindParam (':nome2', $oldNome);
           } catch (PDOException $erro){
               echo "Não foi possível atualizar os dados". $erro->getMessage();
           }
   }
   public function atualizarEmail(){
       //Executa uma query que atualiza o banco
   }
   public function atualizarSenha(){
       //Executa uma query que atualiza o banco
   }
   public function exibeDados(){
       //Executa uma query que da um select no banco
   }
   public function getPdo() {
   }
}
						
I don’t use PDO, but it won’t be to be
:nomeinstead of':nome', removing the', as well as other values of':cpf'that would be:cpf...– Inkeliz
@inkeliz Neither is, man, I tried to trade and nothing, worse than he performs the echo of registered successfully, but does not insert the data in the database, to dying here already uahsuahsuha a a week p insert data in a bank.
– Tiago Silveira