Advertisement
Guest User

Untitled

a guest
Sep 20th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. $sql = "SELECT t.Ativo, t.Nome, t.Idade
  2. FROM tabela t
  3. WHERE t.Id = :id";
  4. $consulta = $this->bd->prepare($sql);
  5. $consulta->bindValue(":id", 3, PDO::PARAM_STR);
  6. $consulta->execute();
  7. $registros = $consulta->fetchAll();
  8. if (count($registros) > 0) {
  9. $this->objeto = $registros[0];
  10. }
  11.  
  12. function __construct($dsn, $username=null, $password=null, $driver_options=null) {
  13. $driver_options = array(PDO::ATTR_STRINGIFY_FETCHES => false);
  14. $this->db = new PDO($dsn, $username, $password, $driver_options);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement