I wish to get tables list into array from database and also the column names of the specific table into array in Drupal. Please mention the queries in Drupal. Thanks

If you wish to create the structure of not what's really within the database, but exactly how the modules you've triggered defined it, you are able to invoke hook_schema for triggered modules. There's really an API call for this, so all you want do would be to call [cde]

It is really an easy method of getting the data, however it will not touch the database, so any table by hand produced with SQL, or tables that are not originating from Drupal, or modifications that's been created using raw SQL will not be located. However, in 99.9% of cases it will likely be accurate.



Do This

global $db_url;
$db_name = explode("/",$db_url);
$dbname = $db_name[count($db_name)-1];
$tables_list = db_query("SHOW tables FROM ".$dbname." WHERE Tables_in_".$dbname." LIKE 'acc%'");
$list_of_tables = array();
while ($result = db_fetch_array($tables_list)) {
drupal_set_message(t('Table name : @db',array('@db'=>$result['Tables_in_'.$dbname.''])));
$list_of_tables[] = $result['Tables_in_'.$dbname.''];
//$list_of_tables array contains tables in database.

$columns = db_query("SHOW FIELDS FROM node");
$list_of_columns = array();
while ($res = db_fetch_array($columns)) {
drupal_set_message(t('Column name : @c',array('@c'=>$res['Field'])));
$list_of_columns[] = $res['Field']; 
//$list_of_columns contains columns in the node table.