Foreach Table in a Database -- Is it possible?
Moderator: General Moderators
-
the9ulaire
- Forum Commoner
- Posts: 74
- Joined: Mon Jun 11, 2007 11:31 am
Foreach Table in a Database -- Is it possible?
Is it possible to do some sort of query of a foreach on a database? Selecting every table name in the database?
Re: Foreach Table in a Database -- Is it possible?
try this:
http://snipplr.com/view/177/mysql-list-database-tables/
http://snipplr.com/view/177/mysql-list-database-tables/
Code: Select all
if (!function_exists('mysql_list_db_tables')) {
function mysql_list_db_tables($database) {
$tables = Array();
$results = mysql_query('SHOW TABLES FROM ' . $database);
while($row = @mysql_fetch_assoc($results)) {
$tables[] = $row['Tables_in_' . $database];
}
return $tables;
}
}Re: Foreach Table in a Database -- Is it possible?
It is preferred to use the query as shown above .. 'SHOW TABLES FROM `database`' instead of the listing tables functions.
I recently wrote a query manager. Was kinda cool.. like a very very lightweight phpmyadmin.
I recently wrote a query manager. Was kinda cool.. like a very very lightweight phpmyadmin.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.