Home » Database » DB » Bug #2307
numRows() not working properly
Details
| Submitted | 2004-09-10 08:36 UTC |
|---|---|
| From | cw at box dot io |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 5.0.1 |
| OS | Linux |
| 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"