note 56922 added to function.mysql-fetch-row

From: Date: Mon, 19 Sep 2005 17:25:24 +0000
Subject: note 56922 added to function.mysql-fetch-row
Groups: php.notes 
Request: Send a blank email to php-notes+get-95415@lists.php.net to get a copy of this message
The function in the previous comment is a little bit inefficient. There's no need for tracking an index variable or calling mysql_num_rows after every iteration. Try this: <?php function mysql_fetch_all($result) { for($row = mysql_fetch_array($result); $row; $row = mysql_fetch_array($result)) { $return[] = $row; } return $return; } ?> This produces the same output as the previous function. ---- Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-row.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56922 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56922&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56922&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56922&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56922&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56922&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+56922&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56922&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56922&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95415) next »