Advertisement
Guest User

Untitled

a guest
Dec 14th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2.  
  3. class Conn extends PDO {
  4. private $user='postgres';
  5. private $pass='202020';
  6. private $options=null;
  7.  
  8. private static $instance;
  9.  
  10. function __construct() {
  11. try {
  12. parent::__construct('pgsql:host=localhost;dbname=banco1', $this->user, $this->pass, $this->options);
  13. } catch (PDOException $ex) {
  14. print ($ex->getMessage());
  15. }
  16. }
  17. public static function getInstance() {
  18. if (!isset(self::$instance)) {
  19. self::$instance = new Conn();
  20. }
  21. return (self::$instance);
  22. }
  23.  
  24. function __destruct() {
  25. self::$instance = null;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement