Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function DatabaseSchema::getPrefixInfo

Get information about the table name and schema from the prefix.

Parameters

Name of table to look prefix up for. Defaults to 'default' because thats: default key for prefix.

$add_prefix: Boolean that indicates whether the given table name should be prefixed.

Return value

A keyed array with information about the schema, table name and prefix.

16 calls to DatabaseSchema::getPrefixInfo()
DatabaseSchema::buildTableNameCondition in includes/database/schema.inc
Build a condition to match a table name against a standard information_schema.
DatabaseSchema::prefixNonTable in includes/database/schema.inc
Create names for indexes, primary keys and constraints.
DatabaseSchema_pgsql::ensureIdentifiersLength in includes/database/pgsql/schema.inc
Make sure to limit identifiers according to PostgreSQL compiled in length.
DatabaseSchema_pgsql::fieldExists in includes/database/pgsql/schema.inc
Check if a column exists in the given table.
DatabaseSchema_pgsql::getComment in includes/database/pgsql/schema.inc
Retrieve a table or column comment.

... See full list

1 method overrides DatabaseSchema::getPrefixInfo()
DatabaseSchema_mysql::getPrefixInfo in includes/database/mysql/schema.inc
Get information about the table and database name from the prefix.

File

includes/database/schema.inc, line 238

Class

DatabaseSchema
Base class for database schema definitions.

Code

protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
 $info = array(
 'schema' => $this->defaultSchema ,
 'prefix' => $this->connection 
 ->tablePrefix ($table),
 );
 if ($add_prefix) {
 $table = $info['prefix'] . $table;
 }
 // If the prefix contains a period in it, then that means the prefix also
 // contains a schema reference in which case we will change the schema key
 // to the value before the period in the prefix. Everything after the dot
 // will be prefixed onto the front of the table.
 if (($pos = strpos ($table, '.')) !== FALSE) {
 // Grab everything before the period.
 $info['schema'] = substr ($table, 0, $pos);
 // Grab everything after the dot.
 $info['table'] = substr ($table, ++$pos);
 }
 else {
 $info['table'] = $table;
 }
 return $info;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.