Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database {
- public $dbh; // handle of the db connexion
- protected $dbhost;
- protected $dbuser;
- protected $dbpass;
- protected $dbname;
- public function __construct ($dbhost, $dbuser,$dbpass,$dbname) {
- $this->dbhost = $dbhost;
- $this->dbuser = $dbuser;
- $this->dbpass = $dbpass;
- $this->dbname = $dbname;
- try {
- $this->dbh = new PDO("mysql:host=$this->dbhost;dbname=$this->dbname", $this->dbuser, $this->dbpass);
- /*$this->dbh->exec("SET CHARACTER SET utf8");*/
- } catch(PDOException $error) {
- echo $error->getMessage();
- }
- }
- public function getPdo(){
- return $this->dbh;
- }
- public function __destruct() {
- $this->dbh = NULL;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement