Advertisement
Guest User

Untitled

a guest
Sep 27th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. class Database extends PDO {
  2.  
  3. //nombre de base de datos
  4. private $dbname = "patrimonio_senatics";
  5. //nombre de servidor
  6. private $host = "192.168.201.40";
  7. //nombre de usuario de base de datos
  8. private $user = "lcardozo";
  9. //password del usuario
  10. private $pass = "senaticspy";
  11. //puerto
  12. private $port = 5432;
  13.  
  14. private $dbh;
  15.  
  16. //conexión a la base de datos
  17. public function __construct() {
  18. try {
  19. $this->dbh = parent::__construct("pgsql:host=$this->host;port=$this->port;dbname=$this->dbname;user=$this->user;password=$this->pass");
  20. echo "conexión establecida";
  21. } catch(PDOException $e) {
  22. echo $e->getMessage();
  23. }
  24. }
  25.  
  26. //cierre de conexión
  27. public function close_con() {
  28. $this->dbh = null;
  29. }
  30. }
  31.  
  32. $db = new Database();
  33.  
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement