summaryrefslogtreecommitdiff
path: root/adodb.inc.php
diff options
context:
space:
mode:
authorDamien Regad <dregad@mantisbt.org>2024-03-22 21:10:52 +0100
committerDamien Regad <dregad@mantisbt.org>2024-03-22 22:14:03 +0100
commit6c7b6fee98a19a2cb64d2b05cfd02f9e2c8ebe98 (patch)
treef262f7e084e267df8c6c3d0df55b22cedeff0413 /adodb.inc.php
parent172489c55d634b5d01b1f32c8717949784c23396 (diff)
downloadadodb-6c7b6fee98a19a2cb64d2b05cfd02f9e2c8ebe98.tar.gz
adodb-6c7b6fee98a19a2cb64d2b05cfd02f9e2c8ebe98.tar.bz2
adodb-6c7b6fee98a19a2cb64d2b05cfd02f9e2c8ebe98.zip
Fix getAssoc() with ADODB_FETCH_DEFAULT mode
With mysqli (and possibly with other drivers where driver-specific fetchMode values are different from ADOdb's as well, but this has not been tested), getAssoc() would not return the expected key=>value pairs when fetch mode was set to ADODB_FETCH_DEFAULT. We now use ADORecordSet::$adodbFetchMode property as reference fetch mode instead of the driver-specific ADOConnection::$fetchMode (which is often not set), and check it against both ADODB_FETCH_BOTH and ADODB_FETCH_DEFAULT. Fixes #1023
Diffstat (limited to 'adodb.inc.php')
-rw-r--r--adodb.inc.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/adodb.inc.php b/adodb.inc.php
index 7683c8e1..fce37df0 100644
--- a/adodb.inc.php
+++ b/adodb.inc.php
@@ -4300,6 +4300,8 @@ class ADORecordSet implements IteratorAggregate {
*/
function getAssoc($force_array = false, $first2cols = false)
{
+ global $ADODB_FETCH_MODE;
+
/*
* Insufficient rows to show data
*/
@@ -4322,8 +4324,8 @@ class ADORecordSet implements IteratorAggregate {
* Get the fetch mode when the call was executed, this may be
* different than ADODB_FETCH_MODE
*/
- $fetchMode = $this->connection->fetchMode;
- if ($fetchMode == ADODB_FETCH_BOTH) {
+ $fetchMode = $this->adodbFetchMode;
+ if ($fetchMode == ADODB_FETCH_BOTH || $fetchMode == ADODB_FETCH_DEFAULT) {
/*
* If we are using BOTH, we present the data as if it
* was in ASSOC mode. This could be enhanced by adding
@@ -4355,7 +4357,7 @@ class ADORecordSet implements IteratorAggregate {
$myFields = $this->fields;
- if ($fetchMode == ADODB_FETCH_BOTH) {
+ if ($fetchMode == ADODB_FETCH_BOTH || $fetchMode == ADODB_FETCH_DEFAULT) {
/*
* extract the associative keys
*/