public function __construct() { parent::__construct(); $config = Config::getConfig("db"); $this->mysqli = new \mysqli($config["server"], $config["username"], $config["password"], $config["name"], $config["port"]); if ($this->mysqli->connect_errno) { $this->throwDBExceptionOnError($this->mysqli->connect_error, $this->mysqli->connect_errno); } }
function __construct(\mysqli $mysqli_con = null) { parent::__construct(); $config = Config::getConfig("db"); if (!$mysqli_con) { @($this->mysqli_con = new \mysqli($config["server"], $config["username"], $config["password"], $config["name"], $config["port"])); if ($this->mysqli_con->connect_errno) { $this->throwDBExceptionOnError($this->mysqli_con->error, $this->mysqli_con->errno); } } else { $this->mysqli_con = $mysqli_con; } }