You are here

public function LegacyPdoSessionHandler::__construct in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Session/Storage/Handler/LegacyPdoSessionHandler.php \Symfony\Component\HttpFoundation\Session\Storage\Handler\LegacyPdoSessionHandler::__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

vendor/symfony/http-foundation/Session/Storage/Handler/LegacyPdoSessionHandler.php, line 73

Class

LegacyPdoSessionHandler
Session handler using a PDO connection to read and write data.

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;
  $dbOptions = array_merge(array(
    'db_id_col' => 'sess_id',
    'db_data_col' => 'sess_data',
    'db_time_col' => 'sess_time',
  ), $dbOptions);
  $this->table = $dbOptions['db_table'];
  $this->idCol = $dbOptions['db_id_col'];
  $this->dataCol = $dbOptions['db_data_col'];
  $this->timeCol = $dbOptions['db_time_col'];
}