Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class Database{
  2. private $db_host = "localhost";
  3. private $db_user = "123346";
  4. private $db_pass = "12345";
  5. private $db_name = "1234";
  6. public $conn;
  7. // Create connection
  8. public function connect(){
  9. if(!isset($this->conn)){
  10. $this->conn = new mysqli_connect($this->db_host,$this->db_user,$this->pass,$this->db_name);
  11.  
  12. if($this->conn){
  13. $this->conn = true;
  14. return true;
  15. }else{
  16. $this->conn = false;
  17. return false;
  18. }
  19. }
  20. }
  21. public function disconnect(){
  22. if(isset($this->conn)){
  23. if(mysqli_close($this->conn)){
  24. $this->myconn = false;
  25. echo "connection closed";
  26. return true;
  27. } else{
  28. echo "failed to close connection";
  29. return false;
  30. }
  31. }else{
  32. echo "no connection prescent";
  33. }
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement