Edit report at http://bugs.php.net/bug.php?id=52115&edit=1
ID: 52115 Updated by: and...@php.net Reported by: uramihsayibok at gmail dot com Summary: mysqli_result::fetch_all returns null, not an empty array -Status: Open +Status: Closed Type: Bug Package: MySQLi related Operating System: Win 7 PHP Version: 5.3.2 -Assigned To: +Assigned To: mysql New Comment: Fix will appear in 5.3.3 Previous Comments: ------------------------------------------------------------------------ [2010-06-18 19:25:43] and...@php.net Automatic comment from SVN on behalf of andrey Revision: http://svn.php.net/viewvc/?view=revision&revision=300581 Log: Fix for bug #52115 mysqli_result::fetch_all returns null, not an empty array ------------------------------------------------------------------------ [2010-06-17 23:25:54] uramihsayibok at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=52115&edit=1