Tripal
Functions
Chado Custom Tables

Functions

 chado_edit_custom_table (int $table_id, string $table_name, array $schema, bool $skip_if_exists=True)
 
 chado_create_custom_table (string $table, array $schema, bool $skip_if_exists=TRUE, int $mview_id=NULL, bool $redirect=TRUE)
 
 chado_validate_custom_table_schema ($schema_array)
 
 chado_get_custom_table_id (string $table_name)
 
 chado_get_custom_table_names ($include_mview=TRUE)
 
 chado_delete_custom_table (int $table_id)
 

Detailed Description

Provides an application programming interface (API) for managing Chado tables.

Function Documentation

◆ chado_create_custom_table()

chado_create_custom_table ( string  $table,
array  $schema,
bool  $skip_if_exists = TRUE,
int  $mview_id = NULL,
bool  $redirect = TRUE 
)

Add a new table to the Chado schema.

Deprecated:

Please use the new "tripal_chado.custom_table" service instead.

WARNING This function only supports creation of custom tables in the default Chado schema. Also, for Tripal v4 the $redirect and $mview_id arguments no longer have meaning.

This function is simply a wrapper for built-in database functionality provided by Drupal, but ensures the table is created inside the Chado schema rather than the Drupal schema.

If the table already exists then it will be dropped and recreated using the schema provided. However, it will only drop a table if it exsits in the tripal_custom_tables table. This way the function cannot be used to accidentally alter existing non custom tables. If $skip_if_exists is set then the table is simply added to the tripal_custom_tables and no table is created in Chado.

Parameters
string$tableThe name of the custom table.
array$schemaAn array contiaining a Drupal table schema definition
bool$skip_if_existsTrue to skip changing the table if it exists. False, to change the table. This may result in lost data.
int$mview_idIf this custom table is a materialized view, the mview ID.
bool$redirectIf this form should redirect to a new page.
Drupal\tripal_chado\Database\ChadoConnection$chadoA ChadoConnection instance. If none is proivded then the default chado installation is used.
Returns
bool True if the table was created successfully, False otherwise.

◆ chado_delete_custom_table()

chado_delete_custom_table ( int  $table_id)

Deletes the specified table

Deprecated:

Please use the new "tripal_chado.custom_table" service instead.

WARNING: This function only supports deleting custom tables in the default Chado schema.

Parameters
int$table_idThe numeric custom table ID.
Returns
bool True if the table was sucessfully deleted, False otherwise.

◆ chado_edit_custom_table()

chado_edit_custom_table ( int  $table_id,
string  $table_name,
array  $schema,
bool  $skip_if_exists = True 
)

Edits a known custom table in the chado database.

Deprecated:

Please use the new "tripal_chado.custom_table" service instead.

WARNING This function only supports editing of custom tables in the default Chado schema.

"Known" custom tables are tables that exist in the tripal_custom_tables already. If it is not in tripal_custom_tables, or the specified table does not exist, it will not attempt to make changes. It will also fail if the specified table is a materialized view.

Parameters
int$table_idThe numeric custom table ID.
string$table_nameThe table name,
array$schemaAn array containing the Drupal table schema.
bool$skip_if_existsTrue if the table should not be changed if it already exists. False, to change it regardles.
Returns
bool True if the table was edited succesfully, False otherwise.

◆ chado_get_custom_table_id()

chado_get_custom_table_id ( string  $table_name)

Retrieve the custom table ID of the specified name

Deprecated:

Please use the \Drupal\tripal_chado\ServicesChadoCustomTable::findByName() funct instead.

Parameters
string$table_nameThe name of the custom table.
Returns
int The unique identifier for the given table if it exists.

◆ chado_get_custom_table_names()

chado_get_custom_table_names (   $include_mview = TRUE)

Retrieve a list of all Chado custom table names.

Deprecated:

Please use the \Drupal\tripal_chado\Services\ChadoCustomTable::getTables() function instead.

WARNING: This function only supports geting custom tables in the default Chado schema.

Parameters
boolean$include_mviewTrue if the list of custom tables should include materialized views.
Returns
array An associative array where the key and value pairs are the table name.

◆ chado_validate_custom_table_schema()

chado_validate_custom_table_schema (   $schema_array)

Validate a Drupal Schema API array prior to creating a custom table.

Deprecated:

Please use the \Drupal\tripal_chado\ChadoCustomTables\ChadoCustomTable::validateTableSchema() function instead.

This function can be used in a form validate function or whenever a schema is provided by a user and needs validation.

Parameters
array$schema_arrayAn Drupal Schema API compatible array
Returns
string An empty string for success or a message string for failure