|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39849 mysqli_stmt_num_rows returns 0 for queries with both 0 and 1 row results
Submitted: 2006-12-16 01:55 UTC Modified: 2006-12-16 09:35 UTC
From: cody at codymays dot net Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5CVS-2006-12-16 (snap) OS: OSX 10.4.8 x86
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
9 - 5 = ?
Subscribe to this entry?

 [2006-12-16 01:55 UTC] cody at codymays dot net
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);
                        /* Get the results */
                        $stmt->bind_result($id, $query_count);
                        /* $stmt->num_rows is an alias for mysqli_stmt_num_rows() */

Expected result:
A return of 0 on 0 row results and 1 on 1 row results

Actual result:
Return value of 0


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-16 09:35 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 12:01:28 2024 UTC