Advertisement
Guest User

Untitled

a guest
Oct 29th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.     class Database
  3.     {
  4.         /*private $host = "localhost";
  5.         private $db_name = "reshipping";
  6.         private $username = "root";
  7.         private $password = "";
  8.         public $conn;*/
  9.  
  10.         private $host = "localhost";
  11.         private $db_name = "sumki32_resh";
  12.         private $username = "sumki32_me";
  13.         private $password = "Ch#VK$0lMl=S";
  14.         public $conn;
  15.  
  16.         public function dbConnection()
  17.         {
  18.  
  19.             $this->conn = null;
  20.             try
  21.             {
  22.                 $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
  23.                 $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  24.             }
  25.             catch(PDOException $exception)
  26.             {
  27.                 echo "Connection error: " . $exception->getMessage();
  28.             }
  29.  
  30.             return $this->conn;
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement