Skip to content

Instantly share code, notes, and snippets.

@JackStouffer
Created May 14, 2014 14:16
Show Gist options
  • Save JackStouffer/f96083d9b6b2658893e1 to your computer and use it in GitHub Desktop.
Save JackStouffer/f96083d9b6b2658893e1 to your computer and use it in GitHub Desktop.
A simple script to get all tables and their schema from an odbc connection
<?php
$connection = odbc_connect("YOURCONNECTION", "", "");
$result = odbc_tables($connection);
$tables = array();
while (odbc_fetch_row($result))
{
if(odbc_result($result,"TABLE_TYPE")=="TABLE")
{
$table_name = odbc_result($result,"TABLE_NAME");
echo $table_name . "\n";
$odbc_feilds = odbc_columns($connection, null, null, $table_name);
while (odbc_fetch_row($odbc_feilds))
{
echo "\t" . odbc_result($odbc_feilds, "COLUMN_NAME") . "\n";
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment