Exemplo n.º 1
0
 public static function init()
 {
     if (!self::$conn) {
         global $dbhost;
         global $dbuser;
         global $dbpass;
         global $dbname;
         // Open the connection and set the error mode
         self::$conn = new PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname . ';', $dbuser, $dbpass);
         self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         self::$conn->query("SET NAMES 'utf8'");
     }
     return self::$conn;
 }
Exemplo n.º 2
0
 public static function close()
 {
     if (self::$conn) {
         self::$conn = null;
     }
 }