PHPverse 2025

Voting

: max(five, four)?
(Example: nine)

The Note You're Voting On

php dot lpatrick at spamgourmet dot com
17 years ago
Since I was just looking for table descriptions of an MS Access file I didn't know the table structure of, I wrote this (where $inputfile is the Access file name):

<?php
$conn
= odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".$inputfile;, "", "");

$tabs = odbc_tables($conn);
$tables = array();
while (
odbc_fetch_row($tabs)){
if (
odbc_result($tabs,"TABLE_TYPE")=="TABLE") {
$table_name = odbc_result($tabs,"TABLE_NAME");
$tables["{$table_name}"] = array();
$cols = odbc_exec($conn,'select * from `'.$table_name.'` where 1=2'); // we don't want content
$ncols = odbc_num_fields($cols);
for (
$n=1; $n<=$ncols; $n++) {
$field_name = odbc_field_name($cols, $n);
$tables["{$table_name}"]["{$field_name}"]['len'] = odbc_field_len($cols, $n);
$tables["{$table_name}"]["{$field_name}"]['type'] = odbc_field_type($cols, $n);
}
}
}
odbc_close ($conn);
print_r($tables);
?>

<< Back to user notes page

To Top