public static function getInstance($dsn = null, $username = null, $password = null) { if (is_null($dsn) === false) { self::$dsn = $dsn; } if (is_null($username) === false) { self::$username = $username; } if (is_null($password) === false) { self::$password = $password; } try { if (false === is_null(self::$database_handler)) { return self::$database_handler; } self::$database_handler = new \PDO(self::$dsn, self::$username, self::$password); //self::$database_handler->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING ); return self::$database_handler; } catch (\PDOException $pdo_exception) { throw new \Exception(); print_r($pdo_exception); /** * @todo Do something about this error */ } }
public static function getInstance($dsn = null, $username = null, $password = null) { if (is_null($dsn) === false) { self::$dsn = $dsn; } if (is_null($username) === false) { self::$username = $username; } if (is_null($password) === false) { self::$password = $password; } try { if (false === is_null(self::$database_handler)) { return self::$database_handler; } self::$database_handler = new \PDO(self::$dsn, self::$username, self::$password); return self::$database_handler; } catch (\PDOException $pdo_exception) { print_r($pdo_exception); /** * @todo Do something about this error */ } }