function Connection::setPrefix

Same name in this branch
  1. 10 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::setPrefix()
Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::setPrefix()
  2. 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::setPrefix()
  3. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::setPrefix()
  4. 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::setPrefix()

Set the prefix used by this database connection.

Parameters

string $prefix: A single prefix.

1 call to Connection::setPrefix()
Connection::__construct in core/lib/Drupal/Core/Database/Connection.php
Constructs a Connection object.

File

core/lib/Drupal/Core/Database/Connection.php, line 448

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

protected function setPrefix($prefix) {
    assert(is_string($prefix), 'The \'$prefix\' argument to ' . __METHOD__ . '() must be a string');
    $this->prefix = $prefix;
    $this->tablePlaceholderReplacements = [
        $this->identifierQuotes[0] . str_replace('.', $this->identifierQuotes[1] . '.' . $this->identifierQuotes[0], $prefix),
        $this->identifierQuotes[1],
    ];
}

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