Commit f17feb4b authored by Alexander Butenko's avatar Alexander Butenko

Store last statement error as mysqli->error is not including them.

parent 5dbd1c90
...@@ -80,7 +80,12 @@ class MysqliDb ...@@ -80,7 +80,12 @@ class MysqliDb
* @var string * @var string
*/ */
public $count = 0; public $count = 0;
/**
* Variable which holds last statement error
*
* @var string
*/
protected $_stmtError;
/** /**
* @param string $host * @param string $host
* @param string $username * @param string $username
...@@ -158,6 +163,7 @@ class MysqliDb ...@@ -158,6 +163,7 @@ class MysqliDb
} }
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error;
$this->reset(); $this->reset();
return $this->_dynamicBindResults($stmt); return $this->_dynamicBindResults($stmt);
...@@ -175,6 +181,7 @@ class MysqliDb ...@@ -175,6 +181,7 @@ class MysqliDb
$this->_query = filter_var($query, FILTER_SANITIZE_STRING); $this->_query = filter_var($query, FILTER_SANITIZE_STRING);
$stmt = $this->_buildQuery($numRows); $stmt = $this->_buildQuery($numRows);
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error;
$this->reset(); $this->reset();
return $this->_dynamicBindResults($stmt); return $this->_dynamicBindResults($stmt);
...@@ -197,6 +204,7 @@ class MysqliDb ...@@ -197,6 +204,7 @@ class MysqliDb
$this->_query = "SELECT $column FROM $tableName"; $this->_query = "SELECT $column FROM $tableName";
$stmt = $this->_buildQuery($numRows); $stmt = $this->_buildQuery($numRows);
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error;
$this->reset(); $this->reset();
return $this->_dynamicBindResults($stmt); return $this->_dynamicBindResults($stmt);
...@@ -227,6 +235,7 @@ class MysqliDb ...@@ -227,6 +235,7 @@ class MysqliDb
$this->_query = "INSERT into $tableName"; $this->_query = "INSERT into $tableName";
$stmt = $this->_buildQuery(null, $insertData); $stmt = $this->_buildQuery(null, $insertData);
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error;
$this->reset(); $this->reset();
return ($stmt->affected_rows > 0 ? $stmt->insert_id : false); return ($stmt->affected_rows > 0 ? $stmt->insert_id : false);
...@@ -246,6 +255,7 @@ class MysqliDb ...@@ -246,6 +255,7 @@ class MysqliDb
$stmt = $this->_buildQuery(null, $tableData); $stmt = $this->_buildQuery(null, $tableData);
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error;
$this->reset(); $this->reset();
return ($stmt->affected_rows > 0); return ($stmt->affected_rows > 0);
...@@ -265,6 +275,7 @@ class MysqliDb ...@@ -265,6 +275,7 @@ class MysqliDb
$stmt = $this->_buildQuery($numRows); $stmt = $this->_buildQuery($numRows);
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error;
$this->reset(); $this->reset();
return ($stmt->affected_rows > 0); return ($stmt->affected_rows > 0);
...@@ -720,7 +731,7 @@ class MysqliDb ...@@ -720,7 +731,7 @@ class MysqliDb
* @return string * @return string
*/ */
public function getLastError () { public function getLastError () {
return $this->_mysqli->error; return $this->_stmtError . " " . $this->_mysqli->error;
} }
/* Helper functions */ /* Helper functions */
......
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