note 37586 deleted from function.odbc-fetch-array by philip
| From: | philip@php.net | Date: | Sun, 21 Dec 2008 15:13:30 +0000 |
| Subject: | note 37586 deleted from function.odbc-fetch-array by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148418@lists.php.net to get a copy of this message | ||
Note Submitter: frosty dot z at freesbee dot fr
----
Even with PHP 4.2.0 installed this function didn't worked for me (wasn't defined)...
Then I've tried "mysql_fetch_into" : it allowed me to get results into an array, but
array keys were numbers :-/.
So I wrote my own mysql_fetch_array, returning results into an array with field names as keys
($row['login'], $row['password']... instead of $row[0], $row[1]...)
<?
/*
* odbc_fetch_array
*
* parameters :
* - $id_res : result id (e.g. got from an odbc_exec)
*
* returns :
* - a row of the result in an associative array with field names as keys
* - false if there is no more result
*/
function odbc_fetch_array($id_res)
{
unset($ar);
if (odbc_fetch_row($id_res))
{
for ($i = 1; $i <= odbc_num_fields($id_res); $i++)
{
$field_name = odbc_field_name($id_res, $i);
$ar[$field_name] = odbc_result($id_res, $field_name);
}
return $ar;
}
else
{
return false;
}
}
?>