note 26169 added to function.odbc-fetch-array
| From: | garrieDOTpowersATkclDOTacDOTuk at rack1 dot php dot net | Date: | Mon, 21 Oct 2002 11:45:40 +0000 |
| Subject: | note 26169 added to function.odbc-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38353@lists.php.net to get a copy of this message | ||
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);
}
--
http://www.php.net/manual/en/function.odbc-fetch-array.php
http://master.php.net/manage/user-notes.php?action=edit+26169
http://master.php.net/manage/user-notes.php?action=delete+26169
http://master.php.net/manage/user-notes.php?action=reject+26169