Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement