From af809c551852c0bc682b8ced22b67288ff589bd3 Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Mon, 20 Apr 2015 21:28:13 +0000 Subject: [PATCH 1/3] Fix #210 empty getLastQuery after rawQuery() execution --- MysqliDb.php | 1 + 1 file changed, 1 insertion(+) diff --git a/MysqliDb.php b/MysqliDb.php index 7d5be393..8fdc7769 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -237,6 +237,7 @@ public function rawQuery ($query, $bindParams = null, $sanitize = true) $stmt->execute(); $this->_stmtError = $stmt->error; + $this->_lastQuery = $this->replacePlaceHolders ($this->_query, $bindParams); $this->reset(); return $this->_dynamicBindResults($stmt); From f68a33d6ddacbf3840e2deb8c8ae5695c8814a67 Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Mon, 20 Apr 2015 21:28:13 +0000 Subject: [PATCH 2/3] Fix #210 empty getLastQuery after rawQuery() execution --- MysqliDb.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MysqliDb.php b/MysqliDb.php index 7d5be393..d9dbf350 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -218,6 +218,7 @@ public function setPrefix($prefix = '') */ public function rawQuery ($query, $bindParams = null, $sanitize = true) { + $params = array(''); // Create the empty 0 index $this->_query = $query; if ($sanitize) $this->_query = filter_var ($query, FILTER_SANITIZE_STRING, @@ -225,7 +226,6 @@ public function rawQuery ($query, $bindParams = null, $sanitize = true) $stmt = $this->_prepareQuery(); if (is_array($bindParams) === true) { - $params = array(''); // Create the empty 0 index foreach ($bindParams as $prop => $val) { $params[0] .= $this->_determineType($val); array_push($params, $bindParams[$prop]); @@ -237,6 +237,7 @@ public function rawQuery ($query, $bindParams = null, $sanitize = true) $stmt->execute(); $this->_stmtError = $stmt->error; + $this->_lastQuery = $this->replacePlaceHolders ($this->_query, $params); $this->reset(); return $this->_dynamicBindResults($stmt); From 8a2127c57d3264291be9a2fa7a3c2898b9e41b0f Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Tue, 21 Apr 2015 10:37:09 +0000 Subject: [PATCH 3/3] Silence warning on stored procedure call --- MysqliDb.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MysqliDb.php b/MysqliDb.php index d9dbf350..7165bbbf 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -720,6 +720,9 @@ protected function _dynamicBindResults(mysqli_stmt $stmt) $this->count++; array_push($results, $x); } + // stored procedures sometimes can return more then 1 resultset + if ($this->_mysqli->more_results()) + $this->_mysqli->next_result(); if ($this->fetchTotalCount === true) { $this->fetchTotalCount = false;