note 100833 added to function.odbc-fetch-array
| From: | VadimIstratov at osu1 dot php dot net | Date: | Wed, 10 Nov 2010 12:21:44 +0000 |
| Subject: | note 100833 added to function.odbc-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173898@lists.php.net to get a copy of this message | ||
Be careful while using this function with MSSQL for fetching results of SQL queries like following:
"SELECT * FROM table". In this case array will NOT contain named indexes!
I.e.:
Table:
------------------------
| col1 | col2 | col3 |
------------------------
| 1 | 2 | 3 |
------------------------
| 4 | 5 | 6 |
------------------------
Code:
---------------------
$query = "SELECT * FROM table";
$res = odbc_exec($query);
while( $row = odbc_fetch_array($res) ) {
print_r($row);
}
---------------------
Output will be:
---------------------
Array(
[0] => 1,
[1] => 2,
[2] => 3
)
Array(
[0] => 4,
[1] => 5,
[2] => 6
)
---------------------
No field names here!
----
Server IP: 69.147.83.197
Probable Submitter: 195.128.95.36
----
Manual Page -- http://www.php.net/manual/en/function.odbc-fetch-array.php
Edit -- https://master.php.net/note/edit/100833
Del: integrated -- https://master.php.net/note/delete/100833/integrated
Del: useless -- https://master.php.net/note/delete/100833/useless
Del: bad code -- https://master.php.net/note/delete/100833/bad+code
Del: spam -- https://master.php.net/note/delete/100833/spam
Del: non-english -- https://master.php.net/note/delete/100833/non-english
Del: in docs -- https://master.php.net/note/delete/100833/in+docs
Del: other reasons-- https://master.php.net/note/delete/100833
Reject -- https://master.php.net/note/reject/100833
Search -- https://master.php.net/manage/user-notes.php