public function PdoSessionHandler::__construct

Constructor.

List of available options:

  • db_table: The name of the table [required]
  • db_id_col: The column where to store the session id [default: sess_id]
  • db_data_col: The column where to store the session data [default: sess_data]
  • db_time_col: The column where to store the timestamp [default: sess_time]

Parameters

\PDO $pdo A \PDO instance:

array $dbOptions An associative array of DB options:

Throws

\InvalidArgumentException When "db_table" option is not provided

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php, line 46

Class

PdoSessionHandler
PdoSessionHandler.

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

public function __construct(\PDO $pdo, array $dbOptions = array()) {
  if (!array_key_exists('db_table', $dbOptions)) {
    throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.');
  }
  if (\PDO::ERRMODE_EXCEPTION !== $pdo
    ->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))', __CLASS__));
  }
  $this->pdo = $pdo;
  $this->dbOptions = array_merge(array(
    'db_id_col' => 'sess_id',
    'db_data_col' => 'sess_data',
    'db_time_col' => 'sess_time',
  ), $dbOptions);
}