php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74190 mysqli_num_rows return value on error
Submitted: 2017-03-01 10:29 UTC Modified: 2017-03-01 13:46 UTC
From: phpdoc at mail dot my1 dot info Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpdoc at mail dot my1 dot info
New email:
PHP Version: OS:

 

 [2017-03-01 10:29 UTC] phpdoc at mail dot my1 dot info
Description:
------------
---
From manual page: http://www.php.net/mysqli-result.num-rows
---
it doesnt say what gets returned on error (for comparison mysql_num_rows, according to the docs throws false).

by thorwing in a value that cant work (for example a string), it returned NULL and a warning.

since both NULL and 0 are variables that are false-y and according to http://php.net/manual/de/types.comparisons.php#types.comparisions-loose both (NULL == 0) and (NULL == 0) evaluate to true there should be a warning box, noting that strict comparison using === should be appropriate, similar to http://php.net/manual/de/function.strpos.php

Test script:
---------------
<?php
var_dump(mysqli_num_rows("abc"));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-01 13:46 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: Documentation problem +Package: MySQLi related
 [2017-03-01 13:46 UTC] requinix@php.net
mysqli_num_rows() always returns an int so there is no error value in that sense.

Built-in functions normally return NULL when given invalid arguments. It is documented in the functions reference:
http://php.net/manual/en/functions.internal.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 15:01:29 2024 UTC