Guest User

Untitled

a guest
Dec 2nd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public $db_name;
  2. public $db_user;
  3. public $db_pass;
  4. public $db_host;
  5.  
  6. public $connection;
  7.  
  8. public function connection(){
  9. $this->db_host = HOST;
  10. $this->db_user = DB_USERNAME;
  11. $this->db_pass = DB_PASSWORD;
  12. $this->db_name = DB_NAME;
  13.  
  14. $this->connection = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
  15. //return new mysqli('localhost', 'root', '', 'dbcdce');
  16.  
  17. //return $this->connect($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
  18. }
  19.  
  20. function connect($host, $user, $pass, $db_name) {
  21.  
  22. $this->connection = new mysqli($host, $user, $pass, $db_name);
  23.  
  24. if ( mysqli_connect_errno() ) {
  25. printf("Connection failed: %s", mysqli_connect_error());
  26. exit();
  27. }
  28.  
  29. return $this->connection;
  30.  
  31. }
  32.  
  33. public function query($sql)
  34. {
  35. return $this->connection->query($sql);
  36. }
Add Comment
Please, Sign In to add comment