Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     class Database
  4.     {
  5.         private $host="localhost";
  6.         private $username="root";
  7.         private $password="";
  8.         private $db_name="pdoz";
  9.         public $conn;
  10.         public function dbConnection()
  11.         {
  12.             $this->conn=null;
  13.             try
  14.             {
  15.                 $this->conn=new PDO("mysql:host=".$this->host.";dbname=".$this->db_name,$this->username,$this->password);
  16.                 $this->conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  17.             }catch(PDOException $error)
  18.             {
  19.                 print_r($error->getMessage()); 
  20.             }
  21.             return $this->conn;
  22.         }
  23.     }
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement