Reply to Code snipped to output database schema...

Your name:

Reply:


Posted by jonathan.beckett on 02/15/06 17:26

Hi all,

I thought this might be handy for others at some point, so here it
is... a bit of code to output all the table names, field names and
datatypes from a MySQL database. I just had to do it for some
documentation, and didn't fancy writing it all down longhand...

$t_result = mysql_query("SHOW tables");
if ($t_result!=false){
while ($t_row =@ mysql_fetch_array($t_result)){
$table = $t_row[0];
print $table."\n";
$c_result = mysql_query("SHOW columns FROM ".$table);
if ($c_result!=false){
while ($c_row =@ mysql_fetch_array($c_result)){
print $c_row[0].chr(9).$c_row[1]."\n";
}
}
print "\n";
}
}


You never know - it could be handy to somebody one day :)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация