Skip to content

Instantly share code, notes, and snippets.

@kocisov
Created July 17, 2016 15:55
Show Gist options
  • Select an option

  • Save kocisov/81e2278aad2fc247559e2f3f8a38767f to your computer and use it in GitHub Desktop.

Select an option

Save kocisov/81e2278aad2fc247559e2f3f8a38767f to your computer and use it in GitHub Desktop.
Database class
<?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