note 51826 added to function.odbc-fetch-array
| From: | Remy at osu1 dot php dot net | Date: | Tue, 12 Apr 2005 12:35:04 +0000 |
| Subject: | note 51826 added to function.odbc-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87890@lists.php.net to get a copy of this message | ||
I use this function to get my recordset in an array, and it's very easy to use.
function dbquery($sql) {
$arr = array();
$conn = odbc_connect('dsn','user','pass');
$rs = odbc_exec($conn,$sql);
$x = 1;
while (odbc_fetch_row($rs)) {
for ($y = 1; $y <= odbc_num_fields($rs); $y++)
$arr[$x][$y] = odbc_result($rs,$y);
$x++;
}
if ($x > 1)
return $arr;
}
usage:
$arr=dbquery("SELECT * FROM tblTable");
echo $arr[1][1] //echo's first column of the first row
----
Manual Page -- http://www.php.net/manual/en/function.odbc-fetch-array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51826
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51826&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51826&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51826&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51826&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51826&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51826&report=yes
Search -- http://master.php.net/manage/user-notes.php