Tripal
|
Public Member Functions | |
__construct ($version=NULL, $schema_name=NULL) | |
getVersion () | |
getSchemaName () | |
getTableNames ($include_custom=FALSE) | |
getTableSchema ($table) | |
getCustomTableSchema ($table) | |
getBaseTables () | |
getCvtermMapping ($params) | |
checkTableExists ($table) | |
checkColumnExists ($table, $column) | |
checkColumnType ($table, $column, $expected_type=NULL) | |
checkSequenceExists ($table, $column) | |
checkPrimaryKey ($table, $column=NULL) | |
checkConstraintExists ($table, $constraint_name, $type) | |
checkFKConstraintExists ($base_table, $base_column) | |
checkIndexExists ($table, $name) | |
Protected Attributes | |
$version = '' | |
$schema_name = 'chado' | |
Provides an application programming interface (API) for describing Chado tables.
If you need the Drupal-style array definition for any table, use the following:
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:
ChadoSchema::__construct | ( | $version = NULL , |
|
$schema_name = NULL |
|||
) |
The ChadoSchema constructor.
string | $version | The current version for this site. E.g. "1.3". If a version is not provided, the version of the current database will be looked up. |
ChadoSchema::checkConstraintExists | ( | $table, | |
$constraint_name, | |||
$type | |||
) |
Check that the constraint exists.
$table | The table the constraint applies to. |
$constraint_name | The name of the constraint you want to check. |
$type | The type of constraint. Should be one of "PRIMARY KEY", "UNIQUE", or "FOREIGN KEY". |
ChadoSchema::checkFKConstraintExists | ( | $base_table, | |
$base_column | |||
) |
Check the foreign key constrain specified exists.
$base_table | The name of the table the foreign key resides in. E.g. 'feature' for the feature.type_id => cvterm.cvterm_id foreign key. |
$base_column | The name of the column that is a foreign key in. E.g. 'type_id' for the feature.type_id => cvterm.cvterm_id foreign key. |
ChadoSchema::checkIndexExists | ( | $table, | |
$name | |||
) |
A Chado-aware replacement for the db_index_exists() function.
$table | The table to be altered. |
$name | The name of the index. |
ChadoSchema::checkPrimaryKey | ( | $table, | |
$column = NULL |
|||
) |
Check that the primary key exists, has a sequence and a constraint.
$table | The table you want to check the primary key for. |
$column | (OPTIONAL) The name of the primary key column. |
ChadoSchema::checkTableExists | ( | $table | ) |
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
$table | The name of the chado table whose existence should be checked. |
ChadoSchema::getCustomTableSchema | ( | $table | ) |
Retrieves the schema array for the specified custom table.
$table | The name of the table to create. |
ChadoSchema::getCvtermMapping | ( | $params | ) |
Get information about which Chado base table a cvterm is mapped to.
Vocbulary 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:
ChadoSchema::getSchemaName | ( | ) |
Retrieve the name of the PostgreSQL schema housing Chado.
ChadoSchema::getTableNames | ( | $include_custom = FALSE | ) |
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.
$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. |
ChadoSchema::getTableSchema | ( | $table | ) |
Retrieves the chado tables Schema API array.
$table | The name of the table to retrieve. The function will use the appopriate Tripal chado schema API hooks (e.g. v1.11 or v1.2). |
ChadoSchema::getVersion | ( | ) |
Returns the version number of the Chado this object references.