FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=18203&edit=1

ID: 18203
Updated by: danielc@analysisandsolutions.com
Reported By: peter dot bex at solide-ict dot nl
Summary: Type introspection breaks with associative arrays if
names are identical
-Status: Closed
+Status: Open
Type: Bug
Package: MDB2
Operating System: NetBSD/amd64 5.0
Package Version: 2.4.1
PHP Version: 5.3.1
-Assigned To: quipo
+Assigned To: danielc
Roadmap Versions:
New Comment:

-Status: Closed
+Status: Open
-Assigned To: quipo
+Assigned To: danielc
The changes are incomplete.

There is a call to setResultTypesAssoc() in
MDB2_Driver_Common::_wrapResult(). That function does not exist.

Also, the changes only covered some methods. For example, it seems to
have missed MDB2_BufferedResult_oci8::fetchRow(), and possibly others.


Previous Comments:
------------------------------------------------------------------------

[2011-03-06 12:33:51] quipo

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: quipo
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.

---

Thanks a lot for the patch!

------------------------------------------------------------------------

[2011-01-21 15:01:11] sjamaan

I just added a second patch that applies the same change to other
database types than postgres.

------------------------------------------------------------------------

[2011-01-21 15:00:47] sjamaan

Added #patch
bug:18203;patch:assoc_fix-for-other-db-types.patch;revision:1295622047;.

------------------------------------------------------------------------

[2011-01-20 13:53:11] sjamaan

Added #patch bug:18203;patch:assoc_fix.patch;revision:1295531591;.

------------------------------------------------------------------------

[2011-01-20 12:16:06] sjamaan

Description:
------------
When retrieving a result using fetchRow in FETCHMODE_ASSOC, the returned
array types are incorrect if the query contained several columns with
the same name.

This is caused by the fact that when setResultTypes is called, the types
array contains numeric keys. So for example if you obtain an integer,
another integer with the same name and a textfield, you have three
items. The associative array will contain two entries (one of the
identical fields and one textfield), which are mapped to the entries
with the corresponding index, after converting string keys to numbers.

This happens mostly when doing SELECT * on joined tables, but even
though it's bad practice to select *, mdb2 shouldn't fail this hard on
such things.

The attached patch fixes the problem for me.

Test script:
---------------
// Assuming $connection is a previously set up MDB2 connection
$res = $connection->query("SELECT 1 as id, 2 as id, 'foo' as title",
true);
$record = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
var_dump($record); // Prints 'id' => int 2, 'title' => int 0

Expected result:
----------------
I expect 'id' => int 2, 'title' => string 'foo' to be printed.

Actual result:
--------------
'id' => int 2, 'title' => int 0

------------------------------------------------------------------------

Search Discussions

  • Danielc at Dec 19, 2011 at 7:36 pm
    Edit report at https://pear.php.net/bugs/bug.php?id=18203&edit=1

    ID: 18203
    Updated by: danielc@analysisandsolutions.com
    Reported By: peter dot bex at solide-ict dot nl
    Summary: Type introspection breaks with associative arrays if
    names are identical
    -Status: Assigned
    +Status: Closed
    Type: Bug
    Package: MDB2
    Operating System: NetBSD/amd64 5.0
    Package Version: 2.4.1
    PHP Version: 5.3.1
    Assigned To: danielc
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    Fixed in revisions 321234 and 321210. They'll be in the next release
    (which will either be 2.5.0b4 or 2.5.0RC1). This is related to bug
    #9502.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-12-16 17:44:07] danielc

    -Status: Closed
    +Status: Open
    -Assigned To: quipo
    +Assigned To: danielc
    The changes are incomplete.

    There is a call to setResultTypesAssoc() in
    MDB2_Driver_Common::_wrapResult(). That function does not exist.

    Also, the changes only covered some methods. For example, it seems to
    have missed MDB2_BufferedResult_oci8::fetchRow(), and possibly others.

    ------------------------------------------------------------------------

    [2011-03-06 12:33:51] quipo

    -Status: Open
    +Status: Closed
    -Assigned To:
    +Assigned To: quipo
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on pear.php.net
    by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.

    ---

    Thanks a lot for the patch!

    ------------------------------------------------------------------------

    [2011-01-21 15:01:11] sjamaan

    I just added a second patch that applies the same change to other
    database types than postgres.

    ------------------------------------------------------------------------

    [2011-01-21 15:00:47] sjamaan

    Added #patch
    bug:18203;patch:assoc_fix-for-other-db-types.patch;revision:1295622047;.

    ------------------------------------------------------------------------

    [2011-01-20 13:53:11] sjamaan

    Added #patch bug:18203;patch:assoc_fix.patch;revision:1295531591;.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    http://pear.php.net/bugs/bug.php?id=18203

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 16, '11 at 4:44p
activeDec 19, '11 at 7:36p
posts2
users1
websitepear.php.net

1 user in discussion

Danielc: 2 posts

People

Translate

site design / logo © 2021 Grokbase