note 96008 deleted from book.mssql by danbrown
| From: | danbrown@php.net | Date: | Wed, 03 Feb 2010 11:51:47 +0000 |
| Subject: | note 96008 deleted from book.mssql by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165622@lists.php.net to get a copy of this message | ||
Note Submitter: Flavio Tubino
----
I had the same problem reported by Exidas and decided to optimize and simplify his function. Enjoy:
<?php
$sql="SELECT * FROM information_schema.tables AS t
JOIN information_schema.columns AS c ON
t.table_catalog=c.table_catalog AND
t.table_schema=c.table_schema AND
t.table_name=c.table_name
ORDER BY t.table_name";
$rs=mssql_query($sql);
$tabela="";
while($r=mssql_fetch_array($rs)){
if($r['TABLE_NAME']!=$tabela){
$tabela=$r['TABLE_NAME'];
echo '<h2>'.$tabela.'</h2>';
}
echo $r['COLUMN_NAME'].' - '.$r['DATA_TYPE'].'<br>';
}
?>