I'm trying to connect using a simle db class. For some reason it only print out "Initiate DB class"
test.php
include 'db.class.php';
echo 'Initiate DB class';
$db = new DB();
echo 'DB class did load';
db.class.php
class DB extends mysqli { private static $instance = null; private function __construct () { parent::init(); $host = 'localhost'; $user = 'root'; $pass = 'MY_PASS'; $dbse = 'MY_DB'; parent::real_connect($host, $user, $pass, $dbse); if (0 !== $this->connect_errno): die('MySQL Error: '. mysqli_connect_error()); //throw new Exception('MySQL Error: '. mysqli_connect_error()); endif; } public function fetch ($sql, $id = null, $one = false) { $retval = array(); if ($res = $this->query($sql)): $index = 0; while ($rs = $res->fetch_assoc()): if ($one): $retval = $rs; break; else: $retval[$id ? $rs[$id] : $index++] = $rs; endif; endwhile; $res->close(); endif; return $retval; }
}
I have tried to search my log files for error but they come out empty.
ini_set('display_errors', '1'); error_reporting(E_ALL);
and run it again. That should (hopefully) print out any errors. – Josh J