db.php 407 B

1234567891011121314151617181920212223242526
  1. <?php
  2. require_once "config.php";
  3. class DB {
  4. private static $instance;
  5. private $dbh;
  6. private function __construct() {
  7. $this->dbh = new PDO('pgsql:dbname='.DB_NAME.';host='.DB_HOST.';port='.DB_PORT,
  8. DB_USER,
  9. DB_PASS);
  10. }
  11. private function __clone() {
  12. //
  13. }
  14. public static function get() {
  15. if (self::$instance == null)
  16. self::$instance = new self();
  17. return self::$instance->dbh;
  18. }
  19. }