Commit 64b5a57b authored by Alexander Butenko's avatar Alexander Butenko Committed by GitHub

Merge pull request #501 from Ettemlevest/master

Adding error number to exception
parents 0f0ca575 3221f248
...@@ -281,7 +281,7 @@ class MysqliDb ...@@ -281,7 +281,7 @@ class MysqliDb
$this->_mysqli = new mysqli($this->host, $this->username, $this->password, $this->db, $this->port); $this->_mysqli = new mysqli($this->host, $this->username, $this->password, $this->db, $this->port);
if ($this->_mysqli->connect_error) { if ($this->_mysqli->connect_error) {
throw new Exception('Connect Error ' . $this->_mysqli->connect_errno . ': ' . $this->_mysqli->connect_error); throw new Exception('Connect Error ' . $this->_mysqli->connect_errno . ': ' . $this->_mysqli->connect_error, $this->_mysqli->connect_errno);
} }
if ($this->charset) { if ($this->charset) {
...@@ -408,7 +408,7 @@ class MysqliDb ...@@ -408,7 +408,7 @@ class MysqliDb
// Failed? // Failed?
if(!$stmt){ if(!$stmt){
throw new Exception("Unprepared Query Failed, ERRNO: ".$this->mysqli()->errno." (".$this->mysqli()->error.")"); throw new Exception("Unprepared Query Failed, ERRNO: ".$this->mysqli()->errno." (".$this->mysqli()->error.")", $this->mysqli()->errno);
}; };
// return stmt for future use // return stmt for future use
...@@ -1136,6 +1136,7 @@ class MysqliDb ...@@ -1136,6 +1136,7 @@ class MysqliDb
// Exceute the query unprepared because LOCK only works with unprepared statements. // Exceute the query unprepared because LOCK only works with unprepared statements.
$result = $this->queryUnprepared($this->_query); $result = $this->queryUnprepared($this->_query);
$errno = $this->mysqli()->errno;
// Reset the query // Reset the query
$this->reset(); $this->reset();
...@@ -1148,7 +1149,7 @@ class MysqliDb ...@@ -1148,7 +1149,7 @@ class MysqliDb
} }
// Something went wrong // Something went wrong
else { else {
throw new Exception("Locking of table ".$table." failed"); throw new Exception("Locking of table ".$table." failed", $errno);
} }
// Return the success value // Return the success value
...@@ -1169,6 +1170,7 @@ class MysqliDb ...@@ -1169,6 +1170,7 @@ class MysqliDb
// Exceute the query unprepared because UNLOCK and LOCK only works with unprepared statements. // Exceute the query unprepared because UNLOCK and LOCK only works with unprepared statements.
$result = $this->queryUnprepared($this->_query); $result = $this->queryUnprepared($this->_query);
$errno = $this->mysqli()->errno;
// Reset the query // Reset the query
$this->reset(); $this->reset();
...@@ -1180,7 +1182,7 @@ class MysqliDb ...@@ -1180,7 +1182,7 @@ class MysqliDb
} }
// Something went wrong // Something went wrong
else { else {
throw new Exception("Unlocking of tables failed"); throw new Exception("Unlocking of tables failed", $errno);
} }
...@@ -1770,8 +1772,9 @@ class MysqliDb ...@@ -1770,8 +1772,9 @@ class MysqliDb
{ {
if (!$stmt = $this->mysqli()->prepare($this->_query)) { if (!$stmt = $this->mysqli()->prepare($this->_query)) {
$msg = $this->mysqli()->error . " query: " . $this->_query; $msg = $this->mysqli()->error . " query: " . $this->_query;
$num = $this->mysqli()->errno;
$this->reset(); $this->reset();
throw new Exception($msg); throw new Exception($msg, $num);
} }
if ($this->traceEnabled) { if ($this->traceEnabled) {
......
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