Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database {
- // PDO Connection Instance
- public $pdoCon;
- // MySQL database
- $serverHost;
- $databaseName;
- $databaseUsername;
- $databasePassword;
- public function __construct(){
- $this->$serverHost = "localhost";
- $this->$databaseName = "accounts";
- $this->$databaseUsername = "root";
- $this->$databasePassword = "";
- }
- // This opens the PDO connection
- function openConnection(){
- $this->$pdoCon = new PDO("mysql:host=". $this->$serverHost . "$serverHost;dbname=" . $this->$databaseName , $this->$databaseUsername, $this->$databasePassword);
- $this->$pdoCon->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
- }
- // This closes the PDO connection
- function closeConnection(){
- $this->$pdoCon = null;
- }
- // This returns a connection interface
- function getConnectionInstance(){
- return $this->$pdoCon;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement