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

ID: 16970
Updated by: danielc@analysisandsolutions.com
Reported By: kikuchan at uranus dot dti dot ne dot jp
Summary: A default value of $result_wrap_class should be true.
-Status: Open
+Status: Assigned
Type: Feature/Change Request
Package: MDB2
Package Version: Unknown
PHP Version: Irrelevant
-Assigned To:
+Assigned To: danielc
Roadmap Versions:
New Comment:

-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: danielc



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

[2010-01-06 06:11:28] kikuchan

Description:
------------
First, please take a look at line #5 in results.

When I want to use MDB2_Iterator in my script as a default,
and I set 'result_wrap_class' option to 'MDB2_Iterator',
but there is no effect.
This is because of default $result_wrap_class is false in query()
function.

In this case, we should write a code like this everytime,
$db->query($sql, null, true, true);
if you want to use 'result_wrap_class' option via setOption() or
$options.

I think the 4th parameter of query() should be used to OVERWRITE
the default 'result_wrap_class' value.

so, I suggest to change a default value of $result_wrap_class to true.

I think this is no harm because the default
$options['result_wrap_class']
is defined as false now.

Test script:
---------------
<?php
require 'MDB2.php';

$db =& MDB2::factory("pgsql://localhost/test");
MDB2::loadFile('Iterator');

echo "1: " . get_class($db->query("SELECT * FROM test", null)) .
"\n";
echo "2: " . get_class($db->query("SELECT * FROM test", null,
true, false)) . "\n";
echo "3: " . get_class($db->query("SELECT * FROM test", null,
true, true)) . "\n";
echo "4: " . get_class($db->query("SELECT * FROM test", null,
true, "MDB2_BufferedIterator")) . "\n";

$db->setOption('result_wrap_class', 'MDB2_Iterator');
echo "5: " . get_class($db->query("SELECT * FROM test", null)) .
"\n";
echo "6: " . get_class($db->query("SELECT * FROM test", null,
true, false)) . "\n";
echo "7: " . get_class($db->query("SELECT * FROM test", null,
true, true)) . "\n";
echo "8: " . get_class($db->query("SELECT * FROM test", null,
true, "MDB2_BufferedIterator")) . "\n";

Expected result:
----------------
1: MDB2_BufferedResult_pgsql
2: MDB2_BufferedResult_pgsql
3: MDB2_BufferedResult_pgsql
4: MDB2_BufferedIterator
5: MDB2_Iterator
6: MDB2_BufferedResult_pgsql
7: MDB2_Iterator
8: MDB2_BufferedIterator

Actual result:
--------------
1: MDB2_BufferedResult_pgsql
2: MDB2_BufferedResult_pgsql
3: MDB2_BufferedResult_pgsql
4: MDB2_BufferedIterator
5: MDB2_BufferedResult_pgsql
6: MDB2_BufferedResult_pgsql
7: MDB2_Iterator
8: MDB2_BufferedIterator

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

Search Discussions

  • Danielc at Dec 20, 2011 at 3:54 am
    Edit report at https://pear.php.net/bugs/bug.php?id=16970&edit=1

    ID: 16970
    Updated by: danielc@analysisandsolutions.com
    Reported By: kikuchan at uranus dot dti dot ne dot jp
    Summary: A default value of $result_wrap_class should be true.
    -Status: Assigned
    +Status: Closed
    Type: Feature/Change Request
    Package: MDB2
    Package Version: Unknown
    PHP Version: Irrelevant
    Assigned To: danielc
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    Changes committed in r321267.


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

    [2011-12-20 03:29:27] danielc

    -Status: Open
    +Status: Assigned
    -Assigned To:
    +Assigned To: danielc


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

    [2010-01-06 06:11:28] kikuchan

    Description:
    ------------
    First, please take a look at line #5 in results.

    When I want to use MDB2_Iterator in my script as a default,
    and I set 'result_wrap_class' option to 'MDB2_Iterator',
    but there is no effect.
    This is because of default $result_wrap_class is false in query()
    function.

    In this case, we should write a code like this everytime,
    $db->query($sql, null, true, true);
    if you want to use 'result_wrap_class' option via setOption() or
    $options.

    I think the 4th parameter of query() should be used to OVERWRITE
    the default 'result_wrap_class' value.

    so, I suggest to change a default value of $result_wrap_class to true.

    I think this is no harm because the default
    $options['result_wrap_class']
    is defined as false now.

    Test script:
    ---------------
    <?php
    require 'MDB2.php';

    $db =& MDB2::factory("pgsql://localhost/test");
    MDB2::loadFile('Iterator');

    echo "1: " . get_class($db->query("SELECT * FROM test", null)) .
    "\n";
    echo "2: " . get_class($db->query("SELECT * FROM test", null,
    true, false)) . "\n";
    echo "3: " . get_class($db->query("SELECT * FROM test", null,
    true, true)) . "\n";
    echo "4: " . get_class($db->query("SELECT * FROM test", null,
    true, "MDB2_BufferedIterator")) . "\n";

    $db->setOption('result_wrap_class', 'MDB2_Iterator');
    echo "5: " . get_class($db->query("SELECT * FROM test", null)) .
    "\n";
    echo "6: " . get_class($db->query("SELECT * FROM test", null,
    true, false)) . "\n";
    echo "7: " . get_class($db->query("SELECT * FROM test", null,
    true, true)) . "\n";
    echo "8: " . get_class($db->query("SELECT * FROM test", null,
    true, "MDB2_BufferedIterator")) . "\n";

    Expected result:
    ----------------
    1: MDB2_BufferedResult_pgsql
    2: MDB2_BufferedResult_pgsql
    3: MDB2_BufferedResult_pgsql
    4: MDB2_BufferedIterator
    5: MDB2_Iterator
    6: MDB2_BufferedResult_pgsql
    7: MDB2_Iterator
    8: MDB2_BufferedIterator

    Actual result:
    --------------
    1: MDB2_BufferedResult_pgsql
    2: MDB2_BufferedResult_pgsql
    3: MDB2_BufferedResult_pgsql
    4: MDB2_BufferedIterator
    5: MDB2_BufferedResult_pgsql
    6: MDB2_BufferedResult_pgsql
    7: MDB2_Iterator
    8: MDB2_BufferedIterator

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 20, '11 at 2:29a
activeDec 20, '11 at 3:54a
posts2
users1
websitepear.php.net

1 user in discussion

Danielc: 2 posts

People

Translate

site design / logo © 2022 Grokbase