Created
April 15, 2014 00:44
-
-
Save kruxor/10692962 to your computer and use it in GitHub Desktop.
show all tables in the selected database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* list db structure */ | |
function show_all_db() { | |
global $db; | |
global $db_name; | |
$out = ""; | |
$sql = "SELECT table_name, column_name | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE table_schema = '$db_name' | |
ORDER BY table_name, ordinal_position"; | |
$result = $db->query($sql); | |
if(!$result) { return "Missing Main Table: $db_name "; } | |
while($row = mysqli_fetch_assoc($result)) { | |
$table_name = $row['table_name']; | |
$column_name = $row['column_name']; | |
$out .= "$table_name : $column_name<br/>"; | |
} | |
return $out; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment