Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PostgreSqlStore.php

function PostgreSqlStore::__construct

You can either pass an existing database connection as PDO instance or a DSN string that will be used to lazy-connect to the database when the lock is actually used.

List of available options:

  • db_username: The username when lazy-connect [default: '']
  • db_password: The password when lazy-connect [default: '']
  • db_connection_options: An array of driver-specific connection options [default: []]

Parameters

array $options An associative array of options:

Throws

InvalidArgumentException When first argument is not PDO nor Connection nor string

InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION

InvalidArgumentException When namespace contains invalid characters

File

vendor/symfony/lock/Store/PostgreSqlStore.php, line 52

Class

PostgreSqlStore
PostgreSqlStore is a PersistingStoreInterface implementation using PostgreSql advisory locks.

Namespace

Symfony\Component\Lock\Store

Code

public function __construct(\PDO|string $connOrDsn, array $options = []) {
    if ($connOrDsn instanceof \PDO) {
        if (\PDO::ERRMODE_EXCEPTION !== $connOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) {
            throw new InvalidArgumentException(\sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)).', __METHOD__));
        }
        $this->conn = $connOrDsn;
        $this->checkDriver();
    }
    else {
        $this->dsn = $connOrDsn;
    }
    $this->username = $options['db_username'] ?? $this->username;
    $this->password = $options['db_password'] ?? $this->password;
    $this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal