· 9 years ago · Nov 15, 2016, 10:42 PM
1FILE 1:
2
3class 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
16FILE 2:
17class 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}