Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2. class access{
  3.     var $host = null;
  4.     var $user = null;
  5.     var $pass = null;
  6.     var $name = null;
  7.     var $conn = null;
  8.    
  9.     //Constructor
  10.     function __construct($dbhost, $dbuser, $dbpass, $dbname) {
  11.        
  12.         $this->host = $dbhost;
  13.         $this->user = $dbuser;
  14.         $this->pass = $dbname;
  15.         $this->name = $dbname;
  16.     }
  17.    
  18.     public function connect(){
  19.         $this->conn = new mysqli($this->host, $this->user, $this->pass, $this->name);
  20.        
  21.         if (mysqli_connect_errno()){
  22.             //Verbindung zur Datenbank fehlgeschlagen
  23.             return false;
  24.         }else{
  25.             //Verbindung zur Datenbank erfolgreich hergestellt;
  26.             return true;
  27.         }
  28.     }
  29.    
  30.     public function disconnect(){
  31.        
  32.         // IF Connection exists
  33.         if ($this->conn != null){
  34.             $this->conn->close();
  35.         }else{
  36.             return;
  37.         }
  38.     }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement