From: cody at codymays dot net
Operating system: OSX 10.4.8 x86
PHP version: 5CVS-2006-12-16 (snap)
PHP Bug Type: MySQLi related
Bug description: mysqli_stmt_num_rows returns 0 for queries with both 0 and 1
row results
Description:
------------
It has come to my attention that trying to test if the number of rows
returned by a prepared statement is somewhat broken. If we try
$stmt->num_rows (alias of mysqli_stmt_num_rows obviously) we get 0 for
results of both 0 and 1 rows.
Reproduce code:
---------------
Below is the code I used to reproduce this action. The structure is pretty
much straight forward. The date field is of the MySQL DATE data type.
if($stmt = $db->prepare("SELECT id, queries FROM
".STATS_TABLE." WHERE date = ? and id = ?"))
{
$stmt->bind_param('si', $date, $this->id);
$stmt->execute();
/* Get the results */
$stmt->bind_result($id, $query_count);
$stmt->fetch();
$stmt->store_result();
/* $stmt->num_rows is an alias for
mysqli_stmt_num_rows() */
echo($stmt->num_rows.'-'.$api_id);
}
Expected result:
----------------
A return of 0 on 0 row results and 1 on 1 row results
Actual result:
--------------
Return value of 0
--
Edit bug report at http://bugs.php.net/?id=39849&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39849&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39849&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39849&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39849&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39849&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39849&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39849&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39849&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39849&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39849&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39849&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39849&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39849&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39849&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39849&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39849&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39849&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39849&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39849&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39849&r=mysqlcfg