FYI: odbc_result contains the following values: TABLE_QUALIFIER TABLE_OWNER TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME PRECISION LENGTH SCALE RADIX NULLABLE REMARKS COLUMN_FLAGS
I wrote the following to dump these values onto the page. I needed this to determine if the data-type for a column was something specific (eg: blob) to show a different result, instead of the actual contents.
$connection_string = 'OPTIM_BLOB';
$user = '';
$pass = '';
if (!($connect = odbc_pconnect($connection_string, $user, $pass))) {
} else {
echo 'Connecting to DSN, loading tables<br /><br />';
$result = odbc_tables($myconn);
$tables = array();
while (odbc_fetch_row($result)){
if(odbc_result($result,"TABLE_TYPE")=="TABLE") {
$TableName = odbc_result($result,"TABLE_NAME");
echo '<span id="tableName">Table: '.$TableName.'</span> ....<br /><br /> ';
//--------- Show Columns in that table ---------------
$result2 = odbc_columns($myconn, '', "%", $TableName, "%"); //db connection, DB name, schema, table name, column_name);
while(odbc_fetch_row($result2)){
//TABLE_QUALIFIER TABLE_OWNER TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME PRECISION LENGTH SCALE RADIX NULLABLE REMARKS COLUMN_FLAGS
$COLUMN_NAME = odbc_result($result2, 4); // COLUMN_NAME
$DataType = odbc_result($result2, 6);
echo '<b>Column name: '.$COLUMN_NAME.'</b> Type: '.$DataType.'<br /><br />';
// everything
echo '1: '.odbc_result($result2, 1).'<br />'; // TABLE_QUALIFIER
echo '2: '.odbc_result($result2, 2).'<br />'; // TABLE_OWNER
echo '3: '.odbc_result($result2, 3).'<br />'; // TABLE_NAME
echo '4: '.odbc_result($result2, 4).'<br />'; // COLUMN_NAME
echo '5: '.odbc_result($result2, 5).'<br />'; // DATA_TYPE (Number)
echo '6: '.odbc_result($result2, 6).'<br />'; // TYPE_NAME (String)
echo '7: '.odbc_result($result2, 7).'<br />'; // PRECISION
echo '8: '.odbc_result($result2, 8).'<br />'; // LENGTH
echo '9: '.odbc_result($result2, 9).'<br />'; // SCALE
echo '10: '.odbc_result($result2, 10).'<br />'; // RADIX
echo '11: '.odbc_result($result2, 11).'<br />'; // NULLABLE
echo '12: '.odbc_result($result2, 12).'<br />'; // REMARKS
echo '13: '.odbc_result($result2, 13).'<br />'; // COLUMN_FLAGS
echo '<br /><br />';
}
}
}
}