function chado_table_exists

2.x tripal_core.chado_schema.api.inc chado_table_exists($table)
3.x tripal_chado.schema.api.inc chado_table_exists($table)

Check that any given Chado table exists.

This function is necessary because Drupal's db_table_exists will not look in any other schema but the one were Drupal is installed

Parameters

$table: The name of the chado table whose existence should be checked.

Return value

TRUE if the table exists in the chado schema and FALSE if it does not.

Related topics

14 calls to chado_table_exists()
chado_add_node_form_properties in tripal_core/api/tripal_core.chado_nodes.properties.api.inc
chado_add_node_form_relationships in tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
Provides a form for adding to BASE_relationship and relationship tables
chado_create_custom_table in tripal_core/api/tripal_core.custom_tables.api.inc
Add a new table to the Chado schema. This function is simply a wrapper for the db_create_table() function of Drupal, but ensures the table is created inside the Chado schema rather than the Drupal schema. If the table already exists then it will be…
chado_delete_custom_table in tripal_core/api/tripal_core.custom_tables.api.inc
Deletes the specified custom table
tripal_add_mview in tripal_core/api/tripal_core.mviews.api.inc
Add a materialized view to the chado database to help speed data access. This function supports the older style where postgres column specifications are provided using the $mv_table, $mv_specs and $indexed variables. It also supports the newer…

... See full list

File

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

Code

function chado_table_exists($table) {
  global $databases;

  $default_db = $databases['default']['default']['database'];

  $sql = "
    SELECT 1
    FROM information_schema.tables
    WHERE
      table_name = :table_name AND
      table_schema = :chado AND
      table_catalog = :default_db
  ";
  $args = array(
    ':table_name' => $table,
    ':chado' => tripal_get_schema_name('chado'),
    ':default_db' => $default_db
  );
  $results = db_query($sql, $args);
  $exists = $results->fetchObject();
  if (!$exists) {
    return FALSE;
  }
  return TRUE;
}