function chado_index_exists

2.x tripal_core.chado_schema.api.inc chado_index_exists($table, $name)

A Chado-aware replacement for the db_index_exists() function.

Parameters

$table: The table to be altered.

$name: The name of the index.

1 call to chado_index_exists()

File

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

Code

function chado_index_exists($table, $name) {
  global $databases;

  $indexname = $table . '_' . $name . '_idx';

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

  $sql = "
      SELECT 1 as exists
      FROM pg_indexes
      WHERE indexname = :indexname
  ";

  $result = db_query($sql, array(':indexname' => $indexname));
  $exists = $result->fetchObject();
  return $exists->exists;
}