note 100833 modified in function.odbc-fetch-array by danbrown

From: Date: Wed, 10 Nov 2010 13:49:38 +0000
Subject: note 100833 modified in function.odbc-fetch-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173903@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: --------------------- <?php $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! --was-- 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! http://php.net/manual/en/function.odbc-fetch-array.php

« previous php.notes (#173903) next »