Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <?php
  2.  
  3. Class Conexao {
  4.  
  5. protected $host = “localhost”;
  6. protected $user = “postgres”;
  7. protected $pswd = “pedro123”;
  8. protected $dbname = “teste”;
  9. protected $con = null;
  10.  
  11. function __construct(){} //método construtor
  12.  
  13. #método que inicia conexao
  14. function open(){
  15. $this->con=@pg_connect(“host=$this->host user=$this->user password=$this->pswd dbname=$this->dbname);
  16.  return $this->con;
  17. }
  18.  
  19. #método que encerra a conexao
  20. function close(){
  21.  @pg_close($this->con);
  22. }
  23.  
  24. #método verifica status da conexao
  25. function statusCon(){
  26.   if(!$this->con){
  27.    echo<h3>O sistema não está conectado à  [$this->dbname] em [$this->host].</h3>;
  28.    exit;
  29.   }
  30.   else{
  31.    echo<h3>O sistema está conectado à  [$this->dbname] em [$this->host].</h3>;
  32.   }
  33.  }
  34. }
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement