--
Você recebeu esta mensagem porque está inscrito no grupo "PHP MG" no grupos do Google.
Site oficial do grupo: http://www.phpmg.com
Para postar neste grupo, envie um e-mail para ph...@googlegroups.com
Para cancelar a sua inscrição neste grupo, envie um e-mail para phpmg-unsubscribe@googlegroups.com
Regras da lista: http://groups.google.com/group/phpmg/web/regras-da-lista
Para ver mais opções, acesse http://groups.google.com/group/phpmg
---
Você recebeu essa mensagem porque está inscrito no grupo "PHP MG" dos Grupos do Google.
Para cancelar inscrição nesse grupo e parar de receber e-mails dele, envie um e-mail para phpmg+unsubscribe@googlegroups.com.
Para mais opções, acesse https://groups.google.com/d/optout.
object(Pessoa)#1 (2) {
["nome"]=>
string(5) "Maria"
["telefone"]=>
string(6) "323366"
}
Ou seja, ele não deve invocar o setNome e nem setTelefone,
mas sim fazer atribuição direta, o que fará com que usar o settype no construtor
não ter efeito como mostrado acima.object(Cliente)#1 (2) {
["nome":"Cliente":private]=>
string(5) "Maria"
["telefone":"Cliente":private]=>
int(323366)
}dados->getId(): 1
object(PDOStatement)#2 (1) { ["queryString"]=> string(21) "select * from cliente" } bool(true) object(Cliente)#3 (3) { ["id":protected]=> int(1) ["nome":"Cliente":private]=> string(14) "Marcelo Ratton" ["dt_nascimento":"Cliente":private]=> string(10) "1977-11-03" } dados->getId(): 2
object(PDOStatement)#2 (1) { ["queryString"]=> string(21) "select * from cliente" } bool(true) object(Cliente)#4 (3) { ["id":protected]=> int(2) ["nome":"Cliente":private]=> string(17) "Jo�o Jos� Geraldo" ["dt_nascimento":"Cliente":private]=> string(10) "1900-04-01" }
| /* |
| * To change this license header, choose License Headers in Project Properties. |
| * To change this template file, choose Tools | Templates |
| * and open the template in the editor. |
| */ |
| namespace app\cgd; |
| use app\cgd\GenericDao; |
| use app\cgd\DBConnection; |
| /** |
| * Description of GenericDAO |
| * |
| * @author Paulo Vianna |
| */ |
| class GenericDao{ |
| private $db; |
| private $entity; |
| public function __construct($entity){ |
| $this->db = new DBConnection(); |
| $this->entity = $entity; |
| } |
| public function find($id){ |
| $query = "Select * from {$this->entity->getTable()} where id=:id"; |
| $stmt = $this->db->getDbconnect()->prepare($query); |
| $stmt->bindValue(':id', $id); |
| $stmt->execute(); |
| return $stmt->fetch((PDO::FETCH_ASSOC)); |
| } |
| //public function listar($ordem = null){ |
| public function listar($ordem) : array{ |
| $query = ""; |
| try{ |
| if($ordem){ |
| $query ="Select * from {$this->entity->getTable()} order by {$ordem}"; |
| } |
| else{ |
| $query ="Select * from {$this->entity->getTable()}"; |
| } |
| $stmt = $this->db->getDbconnect()->query($query); |
| return $stmt->fetchAll(\PDO::FETCH_ASSOC); |
| } |
| catch (PDOException $ex) { |
| # call the get_error function |
| $this->get_error($e); |
| } |
| } |
| public function inserir() : bool { |
| $query = "Insert into {$this->entity->getTable()}(nome, email) Values(:nome, :email)"; |
| $stmt = $this->db->prepare($query); |
| $stmt->bindValue(':nome', $this->entity->getNome()); |
| $stmt->bindValue(':email', $this->entity->getEmail()); |
| if($stmt->execute()){ |
| return true; |
| } |
| else{ |
| return false; |
| } |
| } |
| public function alterar() : bool{ |
| $query = "Update {$this->entity->getTable()} set nome=:nome, email=:email Where id=:id"; |
| $stmt = $this->db->prepare($query); |
| $stmt->bindValue(':id', $this->entity->getId()); |
| $stmt->bindValue(':nome', $this->entity->getNome()); |
| $stmt->bindValue(':email', $this->entity->getEmail()); |
| if($stmt->execute()){ |
| return true; |
| } |
| else{ |
| return false; |
| } |
| } |
| public function deletar($id) : bool { |
| $query = "delete from {$this->entity->getTable()} where id=:id"; |
| $stmt = $this->db->prepare($query); |
| $stmt->bindValue(':id', $id); |
| if($stmt->execute()){ |
| return true; |
| } |
| else{ |
| return false; |
| } |
| } |