|
| __construct ($version=NULL, $schema_name=NULL) |
|
| getVersion () |
|
| getSchemaName () |
|
| getTableNames ($include_custom=FALSE) |
|
| getTableSchema ($table) |
|
| getCustomTableSchema ($table) |
|
| getBaseTables () |
|
| getSchemaDetails () |
|
| checkTableExists ($table) |
|
| checkColumnExists ($table, $column) |
|
| checkColumnType ($table, $column, $expected_type=NULL) |
|
| checkSequenceExists ($table, $column, $sequence_name=NULL) |
|
| checkPrimaryKey ($table, $column=NULL) |
|
| checkConstraintExists ($table, $constraint_name, $type) |
|
| checkFKConstraintExists ($base_table, $base_column) |
|
| checkIndexExists ($table, $name, $no_suffix=FALSE) |
|
| addIndex ($table, $name, $fields, $no_suffix=FALSE) |
|
| createTableSql ($name, $table) |
|
| createFieldSql ($name, $spec) |
|
| processField ($field) |
|
| ensureNotNullPrimaryKey (array $primary_key, array $fields) |
|
| ensureIdentifiersLength ($table_identifier_part, $column_identifier_part, $tag, $separator='__') |
|
Provides an application programming interface (API) for describing Chado tables.
If you need the Drupal-style array definition for any table, use the following:
$chado_schema = new \ChadoSchema();
$table_schema = $chado_schema->getTableSchema($table_name);
where the variable $table contains the name of the table you want to retireve. The getTableSchema method determines the appropriate version of Chado and uses the Drupal hook infrastructure to call the appropriate hook function to retrieve the table schema.
Additionally, here are some other examples of how to use this class:
$chado_schema = new \ChadoSchema('1.2');
$table_schema = $chado_schema->getTableSchema('organism');
$chado_schema = new \ChadoSchema();
$tables = $chado_schema->getTableNames();
$base_tables = $chado_schema->getbaseTables();
$chado_schema = new \ChadoSchema();
$exists = $chado_schema ->checkFKConstraintExists('feature','type_id');
$chado_schema = new \ChadoSchema();
$exists = $chado_schema->checkSequenceExists('organism','organism_id');
$compliant = $chado_schema->checkPrimaryKey('organism');
Drupal\tripal_chado\api\ChadoSchema::checkTableExists |
( |
|
$table | ) |
|
Get information about which Chado base table a cvterm is mapped to.
Vocabulary terms that represent content types in Tripal must be mapped to Chado tables. A cvterm can only be mapped to one base table in Chado. This function will return an object that contains the chado table and foreign key field to which the cvterm is mapped. The 'chado_table' property of the returned object contains the name of the table, and the 'chado_field' property contains the name of the foreign key field (e.g. type_id), and the 'cvterm' property contains a cvterm object.
@params An associative array that contains the following keys:
- cvterm_id: the cvterm ID value for the term.
- vocabulary: the short name for the vocabulary (e.g. SO, GO, PATO)
- accession: the accession for the term.
- bundle_id: the ID for the bundle to which a term is associated. The 'vocabulary' and 'accession' must be used together, the 'cvterm_id' can be used on it's own.
- Returns
- An object containing the chado_table and chado_field properties or NULL if if no mapping was found for the term.
public function getCvtermMapping($params) { return chado_get_cvterm_mapping($params); } 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
- Parameters
-
$table | The name of the chado table whose existence should be checked. |
- Returns
- TRUE if the table exists in the chado schema and FALSE if it does not.