function chado_get_table_names

2.x tripal_core.chado_schema.api.inc chado_get_table_names($include_custom = NULL)
3.x tripal_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_chado_chado_create_table() function.

Related topics

11 calls to chado_get_table_names()
ChadoDatabaseConnection::__construct in tripal_chado/includes/ChadoDatabaseConnection.inc
A replacement constructor for DatabaseConnection_pgsql::__construct.
sio__references::load in tripal_chado/includes/TripalFields/sio__references/sio__references.inc
tripal_bulk_loader_edit_template_record_form in tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc
Edit Record Form
tripal_bulk_loader_template_field_form_default_values in tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc
Determine default values needed for add/edit field form
tripal_chado_populate_chado_semweb_table in tripal_chado/includes/tripal_chado.semweb.inc
Adds defaults to the chado_semweb table.

... See full list

1 string reference to 'chado_get_table_names'

File

tripal_chado/api/tripal_chado.schema.api.inc, line 467
Provides an application programming interface (API) for describing Chado tables.

Code

function chado_get_table_names($include_custom = NULL) {

  // first get the chado version that is installed
  $v = array_key_exists('chado_version', $GLOBALS) ? $GLOBALS["chado_version"] : '';

  $tables = array();
  if ($v == '1.3') {
    $tables_v1_3 = tripal_chado_chado_get_v1_3_tables();
    foreach ($tables_v1_3 as $table) {
      $tables[$table] = $table;
    }
  }
  if ($v == '1.2') {
    $tables_v1_2 = tripal_chado_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_chado_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;
}