function Connection::setTarget

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::setTarget()
  2. 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::setTarget()
  3. 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::setTarget()

Tells this connection object what its target value is.

This is needed for logging and auditing. It's sloppy to do in the constructor because the constructor for child classes has a different signature. We therefore also ensure that this function is only ever called once.

Parameters

string $target: (optional) The target this connection is for.

File

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

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function setTarget($target = NULL) {
    if (!isset($this->target)) {
        $this->target = $target;
    }
}

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