|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-12-16 09:35 UTC] georg@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 00:00:01 2025 UTC |
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