Advertisement
Guest User

Untitled

a guest
Jun 13th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. class Database {
  3.     // PDO Connection Instance
  4.     public $pdoCon;
  5.    
  6.     // MySQL database
  7.     $serverHost;
  8.     $databaseName;
  9.     $databaseUsername;
  10.     $databasePassword;
  11.    
  12.     public function __construct(){
  13.         $this->$serverHost = "localhost";
  14.         $this->$databaseName = "accounts";
  15.         $this->$databaseUsername = "root";
  16.         $this->$databasePassword = "";
  17.     }
  18.    
  19.     // This opens the PDO connection
  20.     function openConnection(){
  21.         $this->$pdoCon = new PDO("mysql:host=". $this->$serverHost . "$serverHost;dbname=" . $this->$databaseName , $this->$databaseUsername, $this->$databasePassword);
  22.         $this->$pdoCon->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  23.     }
  24.    
  25.     // This closes the PDO connection
  26.     function closeConnection(){
  27.         $this->$pdoCon = null;
  28.     }
  29.    
  30.     // This returns a connection interface
  31.     function getConnectionInstance(){
  32.         return $this->$pdoCon;
  33.     }
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement