Advertisement
Guest User

db.php

a guest
Jun 28th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. class Database
  2. {
  3.     private $host;
  4.     private $dbUser;
  5.     private $dbPassword;
  6.     private $dbName;
  7.     private $connect;
  8.    
  9.     public function __construct ($host, $dbUser, $dbPassword, $dbName)
  10.     {
  11.         $this-> host = $host;
  12.         $this-> dbUser = $dbUser;
  13.         $this-> dbPassword = $dbPassword;
  14.         $this-> dbName = $dbName;
  15.     }
  16.    
  17.     public function DBconnection()
  18.     {
  19.         try {
  20.             $db = new PDO('mysql:host='.$this->host.';dbname='.$this->dbName.';charset=utf8', $this->dbUser, $this->dbPassword);
  21.         } catch (PDOException $e) {
  22.             print "Błąd połączenia z bazą!: " . $e->getMessage() . "<br/>";
  23.             die();
  24.         }
  25.     }
  26.    
  27.     public function Close ()
  28.     {
  29.         $this->connect->close();
  30.     }
  31. }
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement