Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. FILE 1:
  2.  
  3. class databaseConnection {
  4.     private $host = 'localhost';
  5.     private $database = 'xxxx';
  6.     private $username = 'xxxx';
  7.     private $password = 'xxxx';
  8.     public $mysqli;
  9.    
  10.     public function __CONSTRUCT() {
  11.         $this->mysqli = new mysqli($this->host,$this->username,$this->password,$this->database);
  12.     }
  13. }
  14.  
  15.  
  16. FILE 2:
  17. class stuff {
  18.  
  19.     public $mysqli;
  20.  
  21.     function __CONSTRUCT() {
  22.         $this->mysqli = new databaseConnection;
  23.     }
  24.  
  25.     function createTable() {
  26.         $query = 'CREATE TABLE IF NOT EXISTS '.$this->tableName.'(';
  27.         $query .= 'key VARCHAR(15),';
  28.         $query .= 'code INT(3),';
  29.         $query .= 'image VARCHAR(255),';
  30.         $query .= 'PRIMARY KEY (key)';
  31.         $query .= ');';
  32.         $this->mysqli($query);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement