Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2. class Persistence {
  3.     const DATA_BASE= 'AboutYou';
  4.     const HOST= 'localhost';
  5.     const USER_DB= 'root';
  6.     const USER_PASSWORD= 123456;
  7.     private static $conn= NULL;
  8.     private static $link= NULL;
  9.    
  10.     private function __construct() {
  11.         self::$link= mysql_connect(self::HOST, self::USER_DB, self::USER_PASSWORD);
  12.         mysql_select_db(self::DATA_BASE);
  13.     }
  14.    
  15.     // Testa se a conexão com o banco existe, se não existe, seta uma nova conexão;
  16.     public static function getConn() {
  17.         if (self::$conn== NULL)
  18.             self::$conn= new Persistence();
  19.         return self::$conn;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement