Created
April 24, 2018 18:36
-
-
Save LouLeGrain/8d94b988703a65422c1cb5cc3fd65630 to your computer and use it in GitHub Desktop.
[Database Access] Class w/ PDO #PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Database | |
{ | |
private static $datasource = 'mysql:host=localhost; dbname=mydbname'; | |
private static $username = 'root'; | |
private static $password = 'root'; | |
private static $pdo; | |
public static function getPDO() | |
{ | |
if (!isset(self::$db)) { | |
self::$pdo = new PDO(self::$datasource, self::$username, self::$password); | |
} | |
return self::$pdo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment