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

Breadcrumb

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

function PdoSessionHandler::getInsertStatement

Returns an insert statement supported by the database for writing session data.

2 calls to PdoSessionHandler::getInsertStatement()
PdoSessionHandler::doRead in vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php
Reads the session data in respect to the different locking strategies.
PdoSessionHandler::doWrite in vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php

File

vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php, line 787

Class

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

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

private function getInsertStatement(string $sessionId, string $sessionData, int $maxlifetime) : \PDOStatement {
    switch ($this->driver) {
        case 'oci':
            $data = fopen('php://memory', 'r+');
            fwrite($data, $sessionData);
            rewind($data);
            $sql = "INSERT INTO {$this->table} ({$this->idCol}, {$this->dataCol}, {$this->lifetimeCol}, {$this->timeCol}) VALUES (:id, EMPTY_BLOB(), :expiry, :time) RETURNING {$this->dataCol} into :data";
            break;
        default:
            $data = $sessionData;
            $sql = "INSERT INTO {$this->table} ({$this->idCol}, {$this->dataCol}, {$this->lifetimeCol}, {$this->timeCol}) VALUES (:id, :data, :expiry, :time)";
            break;
    }
    $stmt = $this->pdo
        ->prepare($sql);
    $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
    $stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
    $stmt->bindValue(':expiry', time() + $maxlifetime, \PDO::PARAM_INT);
    $stmt->bindValue(':time', time(), \PDO::PARAM_INT);
    return $stmt;
}

API Navigation

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