Commit 6d766f61 authored by Steve Müller's avatar Steve Müller

Merge pull request #752 from nicolas-grekas/fix-error-handling

Fix error handling in mysqli driver
parents aea8383c 6285c67a
......@@ -65,21 +65,15 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
$this->setDriverOptions($driverOptions);
$previousHandler = set_error_handler(function () {
});
set_error_handler(function () {});
if ( ! $this->_conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
set_error_handler($previousHandler);
restore_error_handler();
$sqlState = 'HY000';
if (@$this->_conn->sqlstate) {
$sqlState = $this->_conn->sqlstate;
throw new MysqliException($this->_conn->connect_error, @$this->_conn->sqlstate ?: 'HY000', $this->_conn->connect_errno);
}
throw new MysqliException($this->_conn->connect_error, $sqlState, $this->_conn->connect_errno);
}
set_error_handler($previousHandler);
restore_error_handler();
if (isset($params['charset'])) {
$this->_conn->set_charset($params['charset']);
......
......@@ -300,7 +300,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
return false;
}
return $row[$columnIndex];
return isset($row[$columnIndex]) ? $row[$columnIndex] : null;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment