php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80842 Reading num_rows property on unbuffered result should throw an error
Submitted: 2021-03-06 22:25 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: dharman@php.net Assigned:
Status: Open Package: MySQLi related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
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:
MUST BE VALID
Solve the problem:
7 - 5 = ?
Subscribe to this entry?

 
 [2021-03-06 22:25 UTC] dharman@php.net
Description:
------------
Reading mysqli_stmt::num_rows property or calling the method mysqli_stmt::num_rows() should throw an error if using unbuffered results and the result hasn't been fully fetched yet. 

Test script:
---------------
<?php

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli('localhost', 'user', 'password', 'test');
$mysqli->set_charset('utf8mb4'); // always set the charset

$stmt = $mysqli->prepare('SELECT * FROM a LIMIT 2');
$stmt->execute();
echo $stmt->num_rows; // <-- Should trigger OOS error

Expected result:
----------------
Out of sync error

Actual result:
--------------
0

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 04 18:01:28 2024 UTC