I want find all tables in a database.
I want to extract all fields from each table.
I want to extract all values in each field
How to use PHP to do the above?
How to read all tables and fields in a database
Moderator: General Moderators
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
If you are using MySQL the following queries should get you started (it's only a matter of iterating through all the queries that can return multiple rows)
Code: Select all
SHOW DATABASES;
USE database;
SHOW TABLES;
SHOW COLUMNS FROM table;
SELECT DISTINCT column FROM table;- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
I am actually thinking of building a system to create backup the database.
Do you think the commands you specified are the common ones used for a backup operation?
Do I have to run all those commands using mysql_query and use mysql_fetch_array, mysql_num_rows to extract results?
Do I have to write them into a file?
Is there is a standard way how it should be written into a file to read from it later on ?
Do you think the commands you specified are the common ones used for a backup operation?
Do I have to run all those commands using mysql_query and use mysql_fetch_array, mysql_num_rows to extract results?
Do I have to write them into a file?
Is there is a standard way how it should be written into a file to read from it later on ?
Last edited by raghavan20 on Sat Aug 13, 2005 7:43 am, edited 1 time in total.