Skip to content

Instantly share code, notes, and snippets.

@LouLeGrain
Created April 24, 2018 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LouLeGrain/8d94b988703a65422c1cb5cc3fd65630 to your computer and use it in GitHub Desktop.
Save LouLeGrain/8d94b988703a65422c1cb5cc3fd65630 to your computer and use it in GitHub Desktop.
[Database Access] Class w/ PDO #PHP
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