[thelist] Getting the structure of a mysql database through aphp-script
Jay Blanchard
jay.blanchard at niicommunications.com
Wed Oct 1 08:03:50 CDT 2003
[snip]
Short question: how can I get a dump of a database structure using a
php-script? I have access to the site using the database and I want a
quick solution to see how the database is structured.
[/snip]
You can run a MySQL DESCRIBE query in PHP just as you would any other
query.
$sqlDesc = "DESCRIBE tableName ";
$result = mysql_query($sqlDesc, $theconnection);
while($row = mysql_fetch_object($result)){
print($row->foo);
print ...etc....
}
Any query you can run form the MySQL command prompt is executable from
php...
$sqlST = "SHOW TABLES ";
$sqlSPL = "SHOW PROCESSLIST ";
HTH!
More information about the thelist
mailing list