function chado_get_table_names

2.x tripal_core.chado_schema.api.inc chado_get_table_names($include_custom = NULL)

Retrieves the list of tables in the Chado schema. By default it only returns the default Chado tables, but can return custom tables added to the Chado schema if requested

@returns An associative array where the key and value pairs are the Chado table names.

Parameters

$include_custom: Optional. Set as TRUE to include any custom tables created in the Chado schema. Custom tables are added to Chado using the tripal_core_chado_create_table() function.

Related topics

7 calls to chado_get_table_names()
1 string reference to 'chado_get_table_names'

File

tripal_core/api/tripal_core.chado_schema.api.inc, line 417

Code

function chado_get_table_names($include_custom = NULL) {

  // first get the chado version that is installed
  $v = $GLOBALS["chado_version"];

  $tables = array();
  if ($v == '1.3') {
    $tables_v1_3 = tripal_core_chado_get_v1_3_tables();
    foreach ($tables_v1_3 as $table) {
      $tables[$table] = $table;
    }
  }
  if ($v == '1.2') {
    $tables_v1_2 = tripal_core_chado_get_v1_2_tables();
    foreach ($tables_v1_2 as $table) {
      $tables[$table] = $table;
    }
  }
  if ($v == '1.11' or $v == '1.11 or older') {
    $tables_v1_11 = tripal_core_chado_get_v1_11_tables();
    foreach ($tables_v1_11 as $table) {
      $tables[$table] = $table;
    }
  }

  // now add in the custom tables too if requested
  if ($include_custom) {
    $sql = "SELECT table_name FROM {tripal_custom_tables}";
    $resource = db_query($sql);

    foreach ($resource as $r) {
      $tables[$r->table_name] = $r->table_name;
    }
  }

  asort($tables);
  return $tables;
}