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

ID: 16971
Updated by: alec@alec.pl
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: Duplicate
Type: Feature/Change Request
Package: MDB2
Package Version: Unknown
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

-Status: Open
+Status: Duplicate
Duplicate of #16970


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

[2010-01-06 06:17:49] 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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 26, '10 at 1:12p
activeJan 26, '10 at 1:12p
posts1
users1
websitepear.php.net

1 user in discussion

Alec: 1 post

People

Translate

site design / logo © 2022 Grokbase