Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function connect()
$this->_mysqli = new mysqli($this->host, $this->username, $this->password, $this->db, $this->port);

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) {
Expand Down Expand Up @@ -408,7 +408,7 @@ private function queryUnprepared($query)

// Failed?
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
Expand Down Expand Up @@ -1136,6 +1136,7 @@ public function lock($table)

// Exceute the query unprepared because LOCK only works with unprepared statements.
$result = $this->queryUnprepared($this->_query);
$errno = $this->mysqli()->errno;

// Reset the query
$this->reset();
Expand All @@ -1148,7 +1149,7 @@ public function lock($table)
}
// Something went wrong
else {
throw new Exception("Locking of table ".$table." failed");
throw new Exception("Locking of table ".$table." failed", $errno);
}

// Return the success value
Expand All @@ -1169,6 +1170,7 @@ public function unlock()

// Exceute the query unprepared because UNLOCK and LOCK only works with unprepared statements.
$result = $this->queryUnprepared($this->_query);
$errno = $this->mysqli()->errno;

// Reset the query
$this->reset();
Expand All @@ -1180,7 +1182,7 @@ public function unlock()
}
// Something went wrong
else {
throw new Exception("Unlocking of tables failed");
throw new Exception("Unlocking of tables failed", $errno);
}


Expand Down Expand Up @@ -1770,8 +1772,9 @@ protected function _prepareQuery()
{
if (!$stmt = $this->mysqli()->prepare($this->_query)) {
$msg = $this->mysqli()->error . " query: " . $this->_query;
$num = $this->mysqli()->errno;
$this->reset();
throw new Exception($msg);
throw new Exception($msg, $num);
}

if ($this->traceEnabled) {
Expand Down Expand Up @@ -2284,4 +2287,4 @@ private function conditionToSql($operator, $val) {
}
}

// END class
// END class