Created
July 17, 2016 15:55
-
-
Save kocisov/81e2278aad2fc247559e2f3f8a38767f to your computer and use it in GitHub Desktop.
Database class
This file contains hidden or 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
| <?php | |
| class Database extends PDO { | |
| protected $dbHost; | |
| protected $dbName; | |
| protected $dbUser; | |
| protected $dbPass; | |
| public function __construct() { | |
| // assign */a | |
| $dsn = "mysql:host=$this->dbHost;dbname=$this->dbName"; | |
| // ignore this, assign your db configuration here | |
| @call[config#db] | |
| try { | |
| parent::__construct($dsn, $this->dbUser, $this->dbPass); | |
| $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| } catch(PDOException $e) { | |
| throw $e; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment