Guest User

Untitled

a guest
Dec 11th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. public static function getDB()
  2. {
  3. static $db = null;
  4.  
  5. if ($db === null) {
  6. $host = 'localhost';
  7. $dbname = 'php_framework';
  8. $username = 'root';
  9. $password = '';
  10.  
  11. try {
  12. $connection = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
  13.  
  14. return $connection;
  15. } catch (PDOException $e) {
  16. echo $e->getMessage();
  17. }
  18. }
  19. }
Add Comment
Please, Sign In to add comment