1 database.inc protected DatabaseConnection::setPrefix($prefix)

Set the list of prefixes used by this database connection.

Parameters

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

File

core/includes/database/database.inc, line 417
Core systems for the database layer.

Class

DatabaseConnection
Base Database API class.

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[] = '';
}