W3cubDocs

/Drupal 8

protected function Schema::getPrefixInfo

protected Schema::getPrefixInfo($table = 'default', $add_prefix = TRUE)

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

Parameters

Name of table to look prefix up for. Defaults to 'default' because that's: 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.

File

core/lib/Drupal/Core/Database/Schema.php, line 79

Class

Schema
Provides a base implementation for Database Schema.

Namespace

Drupal\Core\Database

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Schema.php/function/Schema::getPrefixInfo/8.1.x