function chado_table_exists

2.x 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


$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/
chado_add_node_form_relationships in tripal_core/api/
Provides a form for adding to BASE_relationship and relationship tables
chado_create_custom_table in tripal_core/api/
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/
Deletes the specified custom table
tripal_add_mview in tripal_core/api/
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


tripal_core/api/, line 41


function chado_table_exists($table) {
  global $databases;

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

  $sql = "
    SELECT 1
    FROM information_schema.tables
      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;