Commit 6d99a554 authored by Nicolas Grekas's avatar Nicolas Grekas Committed by Steve Müller

Fix error handling in mysqli driver

parent dd4d1062
...@@ -65,21 +65,15 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar ...@@ -65,21 +65,15 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
$this->setDriverOptions($driverOptions); $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)) { if ( ! $this->_conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
set_error_handler($previousHandler); restore_error_handler();
$sqlState = 'HY000'; throw new MysqliException($this->_conn->connect_error, @$this->_conn->sqlstate ?: 'HY000', $this->_conn->connect_errno);
if (@$this->_conn->sqlstate) {
$sqlState = $this->_conn->sqlstate;
} }
throw new MysqliException($this->_conn->connect_error, $sqlState, $this->_conn->connect_errno); restore_error_handler();
}
set_error_handler($previousHandler);
if (isset($params['charset'])) { if (isset($params['charset'])) {
$this->_conn->set_charset($params['charset']); $this->_conn->set_charset($params['charset']);
......
...@@ -300,7 +300,7 @@ class MysqliStatement implements \IteratorAggregate, Statement ...@@ -300,7 +300,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
return false; 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