Call to a member function prepare () on a non-object in /var/www/estudos/estudentsCRUD/classes/cliente.php l on line 24

0

object

try
{
    $conexao = new PDO("mysql:host=localhost;dbname=estudos", "root", "");

}catch(PDOExeption $e)
{
    die  ("não foi possovem conectar " . $e->getCode() . ": " . $e->getMessage());
}

$cliente = new Cliente($conexao);

$cliente->setNome("fulano")
        ->setEmail("[email protected]"); 

$resultado = $cliente->inserir();

class

    private $id;
    private $nome;
    private $email;


    public function __contruct(PDO $db)
    {
        $this->db = $db;
    }

    public function listar()
    {}

    public function inserir()
    {

        $query = "Insert into pessoas(nome, email) values(:nome, :email)";

        $stmt = $this->db->prepare($query);
        $stmt->bindValue(':nome', $this->getNome());
        $stmt->bindValue(':email', $this->getEmail());

        $stmt->execute();

    }

    public function alterar()
    {}

    public function deletar()
    {}

    public function setNome($nome)
    {
        $this->nome = $nome;
        return $this;
    }
    public function getNome()
    {
        return $this->nome;
    }

    public function setEmail($email)
    {
        $this->email = $email;
        return $this;
    }
    public function getEmail()
    {
        return $this->email;
    }


    public function setId($id)
    {
        $this->id = $id;
        return $this;
    }
    public function getId()
    {
        return $this->id;
    }








}
    
asked by anonymous 11.03.2017 / 19:39

0 answers