note 42043 deleted from function.mysql-fetch-array by philip

From: Date: Sun, 08 Aug 2004 16:42:45 +0000
Subject: note 42043 deleted from function.mysql-fetch-array by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74244@lists.php.net to get a copy of this message
Note Submitter: rafmav@free.fr ---- This is a variation for the function mysql_fetch_array_r. (Original posted by brendan [at] unsharpmask [dot] com on 24-Nov-2003 09:38 (function mysql_fetch_array_r($result, $index_row = "", $fetch = MYSQL_ASSOC). I wrote this one because I did not want to hold the "$index_row" argument any way. // $result : the result of a sql query // $result_type: the same that mysql_fetch_array function mysql_fetch_array_r($result,$result_type=MYSQL_ASSOC) { $arr=array(); for($i=0;$i<@mysql_num_rows($result);$i++) { // faster ? array_push($arr,@mysql_fetch_array($result,$result_type)); // faster ? } return $arr; // on error, $arr is empty } /* // Uncomment test data for this function $server="localhost"; $user="root"; $password=""; $database="mysql_db"; $sql="SELECT * FROM mysql_table1;"; $link=mysql_connect($server,$user,$password); mysql_select_db($database); $result=mysql_query($sql); $arr=mysql_fetch_array_r($result,MYSQL_ASSOC); if (!empty($arr)) { echo sizeof($arr)."<br />"; print_r($arr); } mysql_free_result($result); mysql_close($link); // */ (This version does not handle errors, sorry).

« previous php.notes (#74244) next »