protected function Connection::setPrefix

Set the list of prefixes used by this database connection.

Parameters

$prefix: The prefixes, in any of the multiple forms documented in default.settings.php.

3 calls to Connection::setPrefix()
Connection::queryTemporary in drupal/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
Runs a SELECT query and stores its results in a temporary table.
Connection::__construct in drupal/core/lib/Drupal/Core/Database/Connection.php
Connection::__construct in drupal/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php

File

drupal/core/lib/Drupal/Core/Database/Connection.php, line 247
Definition of Drupal\Core\Database\Connection

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

protected function setPrefix($prefix) {
  if (is_array($prefix)) {
    $this->prefixes = $prefix + array(
      'default' => '',
    );
  }
  else {
    $this->prefixes = array(
      'default' => $prefix,
    );
  }

  // Set up variables for use in prefixTables(). Replace table-specific
  // prefixes first.
  $this->prefixSearch = array();
  $this->prefixReplace = array();
  foreach ($this->prefixes as $key => $val) {
    if ($key != 'default') {
      $this->prefixSearch[] = '{' . $key . '}';
      $this->prefixReplace[] = $val . $key;
    }
  }

  // Then replace remaining tables with the default prefix.
  $this->prefixSearch[] = '{';
  $this->prefixReplace[] = $this->prefixes['default'];
  $this->prefixSearch[] = '}';
  $this->prefixReplace[] = '';
}