phpLens
 home  products examples manual  faq support forum  contact news  login store

Forums: phplens   adodb
Forums:   ADOdb Help & Dev:   Replies 
Search
Topic: GetAssoc() fails with column with zero index - FIX INCLUDED
author: Detritus   created: 11-06-2012 05:33:33 AM
Affected version: 5.17
5.15 also affected, and I assume previous versions will also be affected.

Example (MySQL):
$DB->GetAssoc('SELECT \'adodb\', \'0\'');

Actual Output:

array(1) {
[0]=>
NULL
}

Expected output:

array(1) {
["adodb"]=>
string(1) "0"
}

There are two fixes for this bug - as I don't know how this affects non-MySQL drivers, I will leave it to the developer to decide which one is best.

FIX 1:
Replace Line 3161:
$numIndex = isset($this->fields[0]);

With:
$numIndex = isset($this->fields[0]) && isset($this->fields[1]);


FIX 2:
Replace Line 3228
$results[trim(($this->fields[0]))] = $this->fields[1];

With:
$v1 = trim(reset($this->fields));
$v2 = ''.next($this->fields);
$results[$v1] = $v2;


Appears I seem to be managing to find some obscure bug in nearly every release...
Topic: Re:GetAssoc() fails with column with zero index - FIX INCLUDED
author: Detritus   created: 11-06-2012 05:47:05 AM
Apologies,

To clarify, only one of the fixes needs to be implemented.
For both of the fixes, the file that needs to be modified is 'adodb.inc.php'
Topic: Re:GetAssoc() fails with column with zero index - FIX INCLUDED
author: John Lim   created: 13-06-2012 04:38:06 AM
Thanks for the fix. Will use FIX 1.

I also had problems replicating the problem until i realised you had set fetching to ADODB_FETCH_ASSOC, which is probably not commonly done.
Page 1
Search

View Source

email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800