private function _mysqli()
{
if (!isset($this->_link)) {
mysqli_report(MYSQLI_REPORT_OFF);
if (!($this->_link = mysqli_init())) {
throw new Exception("Mysql initialization failed");
}
$sqlMode = $this->_strict ? 'TRADITIONAL' : '';
$this->_link->options(MYSQLI_INIT_COMMAND, "SET SESSION sql_mode = '{$sqlMode}'");
$this->_link->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
@$this->_link->real_connect($this->_dsn->host, $this->_dsn->user, $this->_dsn->pass, $this->_dsn->database, $this->_dsn->port);
if ($this->_link->connect_error) {
throw new Exception("Failed to connect to mysql: {$this->_link->connect_error}", $this->_link->connect_errno);
}
if (!$this->_link->set_charset("utf8")) {
throw new Exception(sprintf("Error setting character to %s: %s", $this->_charset, $this->_link->error));
}
}
return $this->_link;
}