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; }
public static function close() { if (self::$conn) { self::$conn = null; } }