version = chado_get_version(TRUE); } else { $this->version = $version; } // Set the name of the schema. if ($schema_name === NULL) { $this->schema_name = chado_get_schema_name('chado'); } else { $this->schema_name = $schema_name; } } /** * Returns the version number of the Chado this object references. * * @returns * The version of Chado */ public function getVersion() { return $this->version; } /** * Retrieve the name of the PostgreSQL schema housing Chado. * * @return * The name of the schema. */ public function getSchemaName() { return $this->schema_name; } /** * 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. * * @param $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. * * @returns * An associative array where the key and value pairs are the Chado table names. */ public function getTableNames($include_custom = FALSE) { $tables = array(); if ($this->version == '1.3') { $tables_v1_3 = tripal_chado_chado_get_v1_3_tables(); foreach ($tables_v1_3 as $table) { $tables[$table] = $table; } } if ($this->version == '1.2') { $tables_v1_2 = tripal_chado_chado_get_v1_2_tables(); foreach ($tables_v1_2 as $table) { $tables[$table] = $table; } } if ($this->version == '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; } /** * Check that any given Chado table exists. * * This function is necessary because Drupal's db_table_exists() function will * not look in any other schema but the one where Drupal is installed * * @param $table * The name of the chado table whose existence should be checked. * * @return * TRUE if the table exists in the chado schema and FALSE if it does not. */ public function checkTableExists($table) { return chado_table_exists($table); } }