php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cody at codymays dot net
New email:
PHP Version: OS:

 

 [2006-12-16 01:55 UTC] cody at codymays dot net
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

Patches

Pull Requests

History

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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 14:01:28 2024 UTC