Skip to content

Commit 7944974

Browse files
Merge pull request #1018 from RivenSkaye/master
Trace Defaults, Bug Fixes (#1001, #1013, #1015, #1016, #1018) Trace Defaults: (Commits: 295c4c6, 057d820) Establishes default settings for tracing mechanisms within the codebase. Bug Fixes: Fixes an error related to calling the end method on an stdClass object (Commit: d181606 - fixes #1001). Resolves issues reported in tickets #1013, #1015, and #1016. Additional Fix (stormwalkerec/php-mysqli-database-class): (Commit: a8de11f - fixes #1018) Merges a separate fix from stormwalkerec/php-mysqli-database-class that addresses another reported issue (#1018).
2 parents 5159467 + 057d820 commit 7944974

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

MysqliDb.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ class MysqliDb
216216
/**
217217
* Variables for query execution tracing
218218
*/
219-
protected $traceStartQ;
220-
protected $traceEnabled;
221-
protected $traceStripPrefix;
219+
protected $traceStartQ = 0;
220+
protected $traceEnabled = false;
221+
protected $traceStripPrefix = '';
222222
public $trace = array();
223223

224224
/**
@@ -790,11 +790,11 @@ public function getOne($tableName, $columns = '*')
790790
/**
791791
* A convenient SELECT COLUMN function to get a single column value from one row
792792
*
793-
* @param string $tableName The name of the database table to work with.
794-
* @param string $column The desired column
795-
* @param int $limit Limit of rows to select. Use null for unlimited..1 by default
793+
* @param string $tableName The name of the database table to work with.
794+
* @param string $column The desired column
795+
* @param int|null $limit Limit of rows to select. Use null for unlimited. 1 by default
796796
*
797-
* @return mixed Contains the value of a returned column / array of values
797+
* @return mixed Contains the value of a returned column / array of values
798798
* @throws Exception
799799
*/
800800
public function getValue($tableName, $column, $limit = 1)
@@ -1689,7 +1689,12 @@ protected function _dynamicBindResults(mysqli_stmt $stmt)
16891689
}
16901690
$this->count++;
16911691
if ($this->_mapKey) {
1692-
$results[$row[$this->_mapKey]] = count($row) > 2 ? $result : end($result);
1692+
if (count($row) < 3 && $this->returnType == 'object') {
1693+
$res = new ArrayIterator($result);
1694+
$res->seek($_res->count() - 1);
1695+
$results[$row[$this->_mapKey]] = $res->current();
1696+
}
1697+
else $results[$row[$this->_mapKey]] = count($row) > 2 ? $result : end($result);
16931698
} else {
16941699
array_push($results, $result);
16951700
}
@@ -2329,7 +2334,7 @@ public function _transaction_status_check()
23292334
*
23302335
* @return MysqliDb
23312336
*/
2332-
public function setTrace($enabled, $stripPrefix = null)
2337+
public function setTrace($enabled, $stripPrefix = '')
23332338
{
23342339
$this->traceEnabled = $enabled;
23352340
$this->traceStripPrefix = $stripPrefix;
@@ -2350,7 +2355,7 @@ private function _traceGetCaller()
23502355
}
23512356

23522357
return __CLASS__ . "->" . $caller["function"] . "() >> file \"" .
2353-
str_replace($this->traceStripPrefix, '', $caller["file"]) . "\" line #" . $caller["line"] . " ";
2358+
str_replace($this->traceStripPrefix , '', $caller["file"]) . "\" line #" . $caller["line"] . " ";
23542359
}
23552360

23562361
/**

0 commit comments

Comments
 (0)