From: Operating system: Win 7 PHP version: 5.3.2 Package: MySQLi related Bug Type: Bug Bug description:mysqli_result::fetch_all returns null, not an empty array
Description:
------------
The documentation says that mysqli_result::fetch_all
- "fetches all result rows and returns the result set as an associative
array, a numeric array, or both"
- "Returns an array of associative or numeric arrays holding result rows"
(though the return type is "mixed").
As far as I can tell, fetch_all returns NULL when there are no rows (ie,
->num_rows==0).
Filed as a bug and not a documentation problem because it'd be nice to
always get an array back.
Test script:
---------------
// Requires that mysqlnd be loaded, of course
// $mysqli = new mysqli(...)
$result = $mysqli->query("SELECT 1 LIMIT 0");
var_dump($result->fetch_all());
Expected result:
----------------
array(0) {
}
Actual result:
--------------
NULL
--
Edit bug report at http://bugs.php.net/bug.php?id=52115&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52115&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52115&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52115&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52115&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52115&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52115&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52115&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52115&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52115&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52115&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52115&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52115&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52115&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52115&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52115&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52115&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52115&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52115&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52115&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52115&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52115&r=mysqlcfg
