From 295c4c61f6e769bbc3e93ffc074528405bf78940 Mon Sep 17 00:00:00 2001 From: Riven Skaye Date: Mon, 24 Jul 2023 15:02:33 +0200 Subject: [PATCH 1/4] Trace defaults, fixes #1016 fixes #1013 --- MysqliDb.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MysqliDb.php b/MysqliDb.php index ab88d03..a85ba37 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -216,9 +216,9 @@ class MysqliDb /** * Variables for query execution tracing */ - protected $traceStartQ; - protected $traceEnabled; - protected $traceStripPrefix; + protected $traceStartQ = 0; + protected $traceEnabled = false; + protected $traceStripPrefix = ''; public $trace = array(); /** @@ -2329,7 +2329,7 @@ public function _transaction_status_check() * * @return MysqliDb */ - public function setTrace($enabled, $stripPrefix = null) + public function setTrace($enabled, $stripPrefix = '') { $this->traceEnabled = $enabled; $this->traceStripPrefix = $stripPrefix; @@ -2350,7 +2350,7 @@ private function _traceGetCaller() } return __CLASS__ . "->" . $caller["function"] . "() >> file \"" . - str_replace($this->traceStripPrefix, '', $caller["file"]) . "\" line #" . $caller["line"] . " "; + str_replace($this->traceStripPrefix , '', $caller["file"]) . "\" line #" . $caller["line"] . " "; } /** @@ -2520,4 +2520,4 @@ private function conditionToSql($operator, $val) { } } -// END class +// END class \ No newline at end of file From 3f6f76febc0d9f733cb19f1e1e7d6ef03fa1b7dc Mon Sep 17 00:00:00 2001 From: Riven Skaye Date: Mon, 24 Jul 2023 15:04:18 +0200 Subject: [PATCH 2/4] fixes #1015 --- MysqliDb.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MysqliDb.php b/MysqliDb.php index a85ba37..9711aeb 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -790,11 +790,11 @@ public function getOne($tableName, $columns = '*') /** * A convenient SELECT COLUMN function to get a single column value from one row * - * @param string $tableName The name of the database table to work with. - * @param string $column The desired column - * @param int $limit Limit of rows to select. Use null for unlimited..1 by default + * @param string $tableName The name of the database table to work with. + * @param string $column The desired column + * @param int|null $limit Limit of rows to select. Use null for unlimited. 1 by default * - * @return mixed Contains the value of a returned column / array of values + * @return mixed Contains the value of a returned column / array of values * @throws Exception */ public function getValue($tableName, $column, $limit = 1) From d18160668eece3aff8ef2ccff468a0d02b10c7f4 Mon Sep 17 00:00:00 2001 From: Riven Skaye Date: Mon, 24 Jul 2023 16:00:00 +0200 Subject: [PATCH 3/4] Prevent calling end on `stdClass`, fixes #1001 --- MysqliDb.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MysqliDb.php b/MysqliDb.php index 9711aeb..209cfb5 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -1689,7 +1689,12 @@ protected function _dynamicBindResults(mysqli_stmt $stmt) } $this->count++; if ($this->_mapKey) { - $results[$row[$this->_mapKey]] = count($row) > 2 ? $result : end($result); + if (count($row) < 3 && $this->returnType == 'object') { + $res = new ArrayIterator($result); + $res->seek($_res->count() - 1); + $results[$row[$this->_mapKey]] = $res->current(); + } + else $results[$row[$this->_mapKey]] = count($row) > 2 ? $result : end($result); } else { array_push($results, $result); } From 057d8203066d1f2aa0f52dfc19f27626455f4fec Mon Sep 17 00:00:00 2001 From: Riven Skaye Date: Mon, 24 Jul 2023 16:24:01 +0200 Subject: [PATCH 4/4] re-add newline before EOF --- MysqliDb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MysqliDb.php b/MysqliDb.php index 209cfb5..0b0d8ae 100644 --- a/MysqliDb.php +++ b/MysqliDb.php @@ -2525,4 +2525,4 @@ private function conditionToSql($operator, $val) { } } -// END class \ No newline at end of file +// END class