public function __construct($first_run = false) { $conn = null; if (!self::$singleton_conn and !$first_run) { $dbconfig = parse_ini_file(get_config_dir() . 'dbsettings.ini'); $db_name = $dbconfig['db_name']; try { $conn = new PDO("mysql:host=localhost;dbname={$db_name};charset=utf8", $dbconfig['db_username'], $dbconfig['db_password'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } catch (PDOException $e) { throw new DatabaseException($e->getMessage()); } $this->conn = self::$singleton_conn = $conn; } $this->conn = self::$singleton_conn; $this->msg = new Messages($GLOBALS['locale']); }