Guest User

dbbbbbb1

a guest
Oct 17th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. $db = isset($_POST['db']) ? $_POST['db'] : '';
  3. class Database
  4. {
  5.  
  6. private $host = "localhost";
  7. private $db_name = "designer3";
  8. private $username = "root";
  9. private $password = "123456";
  10. public $conn;
  11. //$oDb=new Database();
  12.  
  13. public function dbConnection()
  14.  
  15. {
  16. global $DB_con;
  17. $oDb=new Database();
  18. $custDb=$oDb->dbConnection();
  19. $db = isset($_POST['db']) ? $_POST['db'] : '';
  20. $this->conn = null;
  21. try
  22. {
  23.  
  24. $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
  25. $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  26. }
  27. catch(PDOException $exception)
  28. {
  29. echo "Connection error: " . $exception->getMessage();
  30. }
  31.  
  32. $DB_con=$this->conn;
  33. return $this->conn;
  34. }
  35. }
  36. ?>
Add Comment
Please, Sign In to add comment