#39849 [Opn->Bgs]: mysqli_stmt_num_rows returns 0 for queries with both 0 and 1 row results

From: Date: Sat, 16 Dec 2006 09:35:19 +0000
Subject: #39849 [Opn->Bgs]: mysqli_stmt_num_rows returns 0 for queries with both 0 and 1 row results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-106416@lists.php.net to get a copy of this message
ID: 39849 Updated by: georg@php.net Reported By: cody at codymays dot net -Status: Open +Status: Bogus Bug Type: MySQLi related Operating System: OSX 10.4.8 x86 PHP Version: 5CVS-2006-12-16 (snap) New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2006-12-16 01:55:40] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39849&edit=1

« previous php.bugs (#106416) next »