SHARE
TWEET

Untitled

a guest Feb 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class DB{
  3.  
  4. // specify your own database credentials
  5. private $host = "localhost";
  6. private $db_name = "mydomain_infynow_web";
  7. private $username = "mydomain_karthik";
  8. private $password = "9611860475Kar$";
  9. public  $conn;
  10.  
  11. // get the database connection
  12. public function getConnection(){
  13.  
  14.     $this->conn = null;
  15.  
  16.     try{
  17.         $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
  18.          $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  19.         // $this->conn->exec("set names utf8");
  20.     }catch(PDOException $exception){
  21.         echo "Connection error: " . $exception->getMessage();
  22.     }
  23.  
  24.     return $this->conn;
  25. }
  26. // $this->conn = null;
  27. }
  28. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top