/** * Create and return the connection to the database. * * @return PDO object */ private static function get_connection() { if (is_null(self::$db)) { self::$db = new \PDO(sprintf('%s:host=%s;dbname=%s;charset=utf8', DB_TYPE, DB_HOST, DB_NAME), DB_USER, DB_PASS); } return self::$db; }
private function __construct() { $host = DB_HOST; $username = DB_USER; $password = DB_PASS; $dbname = DB_NAME; $db = new \mysqli($host, $username, $password, $dbname); self::$db = $db; }
private function __construct() { // Read the config/db.php db settings $host = DB_HOST; $username = DB_USERNAME; $password = DB_PASSWORD; $database = DB_DATABASE; $db = new \mysqli($host, $username, $password, $database); self::$db = $db; }