note 16413 added to ref.odbc
| From: | vincent at e-line dot be | Date: | Mon, 29 Oct 2001 10:11:32 +0000 |
| Subject: | note 16413 added to ref.odbc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19567@lists.php.net to get a copy of this message | ||
Hi,
I have written a function that returns all the tables/fields of your current odbc connection.
/*
odbc_all (int connection_id)
Description:
The odbc_all() function which is available from PHP 3.06 to PHP 3.0.16 along with PHP 4.0 and
higher
returns all the tables of your open connection.
*/
function odbc_all($odbc_db){
$tablelist = odbc_tables($odbc_db);
$i = 0;
while(odbc_fetch_row($tablelist)){
if (odbc_result($tablelist, 4) == "TABLE"){
$tmp_str = odbc_result($tablelist, 3);
$table_array[$i++] = $tmp_str;
}
}
$i = count($table_array);
while(--$i >= 0){
$result[$i] = odbc_exec($odbc_db, "SELECT * FROM [$table_array[$i]]");
if(!($result[$i])) die(odbc_close($odbc_db));
$source .= "<h3>$table_array[$i]</h3>\n";
$fCount = odbc_num_fields($result[$i]);
for($x=1; $x<=$fCount; $x++){
$fName = odbc_field_name($result[$i], $x);
$source .= "$fName<br>\n";
}
$x=0;
}
return $source;
}
Greetings,
Vincent
PHP is my guiding light, php.net the bible...
--
http://www.php.net/manual/en/ref.odbc.php
http://master.php.net/manage/user-notes.php?action=edit+16413
http://master.php.net/manage/user-notes.php?action=delete+16413
http://master.php.net/manage/user-notes.php?action=reject+16413