PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #2307

numRows() not working properly

Details

Submitted2004-09-10 08:36 UTC
Fromcw at box dot io
Assigneddanielc
StatusBogus
PackageDB
PHP Version5.0.1
OSLinux
Roadmaps(Not assigned)

Comments

[2004-09-10 08:36 UTC] cw at box dot io

Description:
------------
I am using PHP 5.0.1 with the latest DB version 1.6.5. I am connecting via ODBC to a MaxDB database

numRows() is not returning the number of rows if the number is > 0, but it returns something like 'Object id #2'.

When I add "ORDER BY" to my SELECT statement the number of rows is returned correctly sometimes, but not always. It seems to depend on the column type ??

numCols() is always working correctly.

Reproduce code:
---------------
<?php
require_once 'DB.php';

$dsn = array('phptype' => 'odbc', 'username' => 'user', 'password' => 'pass', 'database' => '192.168.1.1:database', );

$options = array( 'debug' => 0, 'portability' => DB_PORTABILITY_ALL, );

$db =& DB::connect($dsn, $options);
if (DB::isError($db)) {
die($db->getMessage());
} else echo "Connection established...<P>";

$res =& $db->query('SELECT * FROM mytable');

echo $res->numRows()."<P>";
echo $res->numCols()."<P>";

$res->free();

$db->disconnect();

?>

Expected result:
----------------
I expect to get the number of rows from numRows().

Actual result:
--------------
If the result has no rows, 0 is returned correctly.

If the result has some rows, "Object id #2" is returned instead of the actual number.

When I add an "ORDER BY" to my SELECT statement the number is returned sometimes, but not always.

[2004-12-10 09:21 UTC] cw at box dot io

Your test script writes "DB Error: not supported"

But when I change
$res =& $db->query('SELECT a FROM blah');
to
$res =& $db->query('SELECT a FROM blah ORDER BY a');

your scripts writes "1"