function chado_sequence_exists

2.x chado_sequence_exists($sequence)

Check that any given column in a Chado table exists.

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


sequence: The name of the sequence

Return value

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

Related topics

1 call to chado_sequence_exists()
tripal_core_upgrade_chado_1_2_to_1_3_pre_alter in tripal_core/includes/
Upgrade custom tables that may match the tables now in Chado v1.3.


tripal_core/api/, line 125


function chado_sequence_exists($sequence) {
  global $databases;

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

  $sql = "
    SELECT 1
    FROM information_schema.sequences
      sequence_name = :sequence_name AND
      sequence_schema = :sequence_schema AND
      sequence_catalog = :sequence_catalog
  $args = array(
    ':sequence_name' => $sequence,
    ':sequence_schema' => tripal_get_schema_name('chado'),
    ':sequence_catalog' => $default_db
  $results = db_query($sql, $args);
  $exists = $results->fetchField();
  if (!$exists) {
    return FALSE;
  return TRUE;