note 37586 added to function.odbc-fetch-array

From: Date: Thu, 20 Nov 2003 10:13:38 +0000
Subject: note 37586 added to function.odbc-fetch-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-60675@lists.php.net to get a copy of this message
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; } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.odbc-fetch-array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37586 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37586&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37586&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60675) next »