Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 KB | None | 0 0
  1. <?
  2.  
  3. class exdb {                                                                                                      
  4.   private static $connection = false;                                                                               private $query;                                                                                                   private $result;                                                                                                                                                                                                                    public function __construct($query, $params=array()) {                                                          
  5.     if (self::$connection === false) {
  6.       $this->connect();
  7.     }
  8.  
  9.     $this->query = $query;
  10.     $this->query();
  11.  
  12.   }
  13.  
  14.   public function connect() {
  15.  
  16.     $host = DB_HOST;
  17.     $user = DB_USER;
  18.     $password = DB_PASSWORD;
  19.     $database = DB_DATABASE;
  20.     self::$connection = new mysqli($host, $user, $password, $database);
  21.  
  22.   }
  23.  
  24.   public function query() {
  25.                                                                                                                       $this->result = self::$connection->query($this->query);
  26.     return $this->result;
  27.  
  28.   }
  29.  
  30.   public function fetch_assoc() {
  31.  
  32.     if (!$row = $this->result->fetch_assoc()) {
  33.       return false;
  34.     }
  35.  
  36.     return $row;
  37.   }
  38.  
  39.   public function __call($name,$args){
  40.     return call_user_func_array(array(self::$connection,$name),$args);
  41.   }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement