note 26169 deleted from function.odbc-fetch-array by philip

From: Date: Sun, 21 Dec 2008 15:13:03 +0000
Subject: note 26169 deleted from function.odbc-fetch-array by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148416@lists.php.net to get a copy of this message
Note Submitter: garrieDOTpowersATkclDOTacDOTuk ---- This function will return all of the rows returned by a query in an array. $resultSet['fieldNames'] contains an array of fieldnames keyed by field number $resultSet[n], where n is the record number, contains an associative array keyed on fieldname. - Garrie ---------------------------------------- function odbc_fetch_resultset($resID) { /* Return all the rows returned by a query in an array. */ $resultSet=array(); // Assign the field names to $resultSet['fieldNames'] $fCount = odbc_num_fields($resID); for ($i=1; $i<= $fCount; $i++){ $fNames[$i] = odbc_field_name($resID, $i); } $resultSet['fieldNames']=$fNames; // Assign the records for ($i=1; odbc_fetch_row($resID,$i); $i++){ $record=array(); for ($j = 1; $j <= $fCount; $j++){ $fName = odbc_field_name($resID, $j); $record[$fName]=odbc_result($resID, $j); } $resultSet[$i]=$record; } return ($resultSet); }

« previous php.notes (#148416) next »