function Schema::getPrefixInfo

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::getPrefixInfo()
Same name and namespace in other branches
  1. 9 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::getPrefixInfo()
  2. 9 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::getPrefixInfo()
  3. 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::getPrefixInfo()
  4. 8.9.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::getPrefixInfo()
  5. 10 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::getPrefixInfo()
  6. 10 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::getPrefixInfo()

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

Return value

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

Overrides Schema::getPrefixInfo

2 calls to Schema::getPrefixInfo()
Schema::buildTableNameCondition in core/modules/mysql/src/Driver/Database/mysql/Schema.php
Build a condition to match a table name against a standard information_schema.
Schema::renameTable in core/modules/mysql/src/Driver/Database/mysql/Schema.php
Rename a table.

File

core/modules/mysql/src/Driver/Database/mysql/Schema.php, line 53

Class

Schema
MySQL implementation of <a href="/api/drupal/core%21lib%21Drupal%21Core%21Database%21Schema.php/class/Schema/11.x" title="Provides a base implementation for Database Schema." class="local">\Drupal\Core\Database\Schema</a>.

Namespace

Drupal\mysql\Driver\Database\mysql

Code

protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) {
    $info = [
        'prefix' => $this->connection
            ->getPrefix(),
    ];
    if ($add_prefix) {
        $table = $info['prefix'] . $table;
    }
    if (($pos = strpos($table, '.')) !== FALSE) {
        $info['database'] = substr($table, 0, $pos);
        $info['table'] = substr($table, ++$pos);
    }
    else {
        $info['database'] = $this->connection
            ->getConnectionOptions()['database'];
        $info['table'] = $table;
    }
    return $info;
}

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