Tripal
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Drupal\tripal_chado\Database\ChadoConnection Class Reference
Inheritance diagram for Drupal\tripal_chado\Database\ChadoConnection:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal_chado\Database\ChadoConnection:
Collaboration graph
[legend]

Public Member Functions

 __construct (string $schema_name='', $database='default', ?\Psr\Log\LoggerInterface $logger=NULL)
 
 getTripalDbxClass ($class)
 
 findVersion (?string $schema_name=NULL, bool $exact_version=FALSE)
 
 getAvailableInstances ()
 
- Public Member Functions inherited from Drupal\tripal\TripalDBX\TripalDbxConnection
 __construct (string $schema_name='', $database='default', ?\Drupal\tripal\Services\TripalLogger $logger=NULL)
 
 getDatabaseName ()
 
 getDatabaseKey ()
 
 getMessageLogger ()
 
 setMessageLogger (\Drupal\tripal\Services\TripalLogger $logger)
 
 schema ()
 
 setSchemaName (string $schema_name)
 
 getSchemaName ()
 
 getQuotedSchemaName ()
 
 getExtraSchemas ()
 
 clearExtraSchemas ()
 
 addExtraSchema (string $schema_name)
 
 setExtraSchema (string $schema_name, int $index=2)
 
 getVersion ()
 
 useTripalDbxSchemaFor ($object_or_class)
 
 useDrupalSchemaFor ($object_or_class)
 
 shouldUseTripalDbxSchema ()
 
 prefixTables ($sql)
 
 tablePrefix ( $table='default', bool $use_tdbx_schema=FALSE)
 
 getPrefix ()
 
 executeSqlQueries (string $sql_queries, $search_path_mode=FALSE, ?string $schema_name=NULL)
 
 executeSqlFile (string $sql_file_path, $search_path_mode=FALSE, ?string $schema_name=NULL)
 
 escapeTable ($table)
 
 getListClassesUsingTripalDbx ()
 
 __toString ()
 

Static Public Member Functions

static removeAllTestSchemas ()
 

Public Attributes

const EMPTY_CHADO_SIZE = 8388608
 
const DEFAULT_VERSION = '1.3'
 

Additional Inherited Members

- Protected Member Functions inherited from Drupal\tripal\TripalDBX\TripalDbxConnection
 getDefaultSchemaName (?string $schema_name=NULL, string $error_message='')
 
- Static Protected Member Functions inherited from Drupal\tripal\TripalDBX\TripalDbxConnection
static openNewPdoConnection (\Drupal\Core\Database\Connection $database)
 
- Protected Attributes inherited from Drupal\tripal\TripalDBX\TripalDbxConnection
 $identifierQuotes
 
 $database = NULL
 
 $databaseName = ''
 
 $dbKey = ''
 
 $usedSchemas = []
 
 $version = NULL
 
 $messageLogger = NULL
 
 $tripalDbxApi = NULL
 
 $objectsUsingTripalDbx = []
 
 $classesUsingTripalDbx = []
 

Detailed Description

Provides an API for Chado schema.

Provides an application programming interface (API) for describing Chado schema and tables. It provides both static and instance methods. Static methods are designed to work regardless any specific Chado schema while instance methods work on a given Chado schema instance specified when the ChadoSchema object is instantiated. Default schema used for instances is 'chado'.

If you need the Drupal-style array definition for any table, use the following:

$chado = new \Drupal\tripal_chado\Database\ChadoConnection();
$parameters = ['format' => 'drupal'];
$table_schema = $chado->schema()->getTableDef($table_name, $parameters);

where the variable $table_name contains the name of the table you want to retireve. The getTableDef method determines the appropriate version of Chado but it can be forced through the $parameters array. See \Drupal\tripal_chado\Database\ChadoSchema::getTableDef for details.

Additionally, here are some other examples of how to use this class:

// Retrieve all chado tables.
$chado = new \Drupal\tripal_chado\Database\ChadoConnection();
$all_tables = $chado->schema()->getTables();
$base_tables = $chado->schema()->getTables(['base' => TRUE,]);
// Check the feature.type_id foreign key constraint.
$chado = new \Drupal\tripal_chado\Database\ChadoConnection();
$exists = $chado->schema()->foreignKeyConstraintExists('feature','type_id');
// Check Sequence exists.
$chado = new \Drupal\tripal_chado\Database\ChadoConnection();
$exists = $chado->schema()->checkSequenceExists('organism','organism_id');
// Or just check the primary key directly.
$compliant = $chado->schema()->checkPrimaryKey('organism');

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal_chado\Database\ChadoConnection::__construct ( string  $schema_name = '',
  $database = 'default',
?\Psr\Log\LoggerInterface  $logger = NULL 
)

{}

Member Function Documentation

◆ findVersion()

Drupal\tripal_chado\Database\ChadoConnection::findVersion ( ?string  $schema_name = NULL,
bool  $exact_version = FALSE 
)

Returns the version number of the given Chado schema.

For recent Chado instances, version is stored in the schema while version number has to be guessed in older versions (using specific table presence).

Parameters
?string$schema_name A schema name or NULL to work on current schema.
bool$exact_versionReturns the most precise version available. Default: FALSE.
Returns
string The version of Chado ('1.0', '1.1x', '1.2x' '1.3x', '1.4+') or '0' if the version cannot be guessed but a Chado instance has been detected or '' if the schema is not a Chado schema.

Reimplemented from Drupal\tripal\TripalDBX\TripalDbxConnection.

◆ getAvailableInstances()

Drupal\tripal_chado\Database\ChadoConnection::getAvailableInstances ( )

Get the list of available Chado instances in current database.

This function returns both Chado schema integrated with Tripal and free Chado schemas.

Returns
array An array of available schema keyed by schema name and having the following structure: "schema_name": name of the schema (same as the key); "version": detected version of Chado; "is_default": TRUE if it is the default Chado schema, FALSE otherwise. "is_test": if it is a test schema, the key of the corresponding prefix as it is set in the config and FALSE otherwise; "is_reserved": the value returned by Drupal\tripal\TripalDBX\TripalDbx::isSchemaReserved; "has_data": TRUE if the schema contains more than just default records; "size": size of the schema in bytes; "integration": FALSE if not integrated with Tripal and an array otherwise with the following fields: 'install_id', 'schema_name', 'version', 'created', 'updated'.

Reimplemented from Drupal\tripal\TripalDBX\TripalDbxConnection.

◆ getTripalDbxClass()

Drupal\tripal_chado\Database\ChadoConnection::getTripalDbxClass (   $class)

{Gets the Tripal DBX-specific class for the specified category.Returns the Tripal DBX-specific override class if any for the specified class category.

Parameters
string$classThe class category for which we want the specific class.
Returns
string The name of the class that should be used.
}

Reimplemented from Drupal\tripal\TripalDBX\TripalDbxConnection.

◆ removeAllTestSchemas()

static Drupal\tripal_chado\Database\ChadoConnection::removeAllTestSchemas ( )
static

Removes all existing Chado test schemas.

Use this function when tests schemas were not removed properly by the automated test system.

Usage: \Drupal\tripal_chado\Database\ChadoConnection::removeAllTestSchemas();

Member Data Documentation

◆ DEFAULT_VERSION

const Drupal\tripal_chado\Database\ChadoConnection::DEFAULT_VERSION = '1.3'

Default Chado schema version.

◆ EMPTY_CHADO_SIZE

const Drupal\tripal_chado\Database\ChadoConnection::EMPTY_CHADO_SIZE = 8388608

Reserved schema name of the Chado schema used for testing.


The documentation for this class was generated from the following file: