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

Breadcrumb

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

function PdoSessionHandler::getUpdateStatement

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

1 call to PdoSessionHandler::getUpdateStatement()
PdoSessionHandler::doWrite in vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php

File

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

Class

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

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

private function getUpdateStatement(string $sessionId, string $sessionData, int $maxlifetime) : \PDOStatement {
    switch ($this->driver) {
        case 'oci':
            $data = fopen('php://memory', 'r+');
            fwrite($data, $sessionData);
            rewind($data);
            $sql = "UPDATE {$this->table} SET {$this->dataCol} = EMPTY_BLOB(), {$this->lifetimeCol} = :expiry, {$this->timeCol} = :time WHERE {$this->idCol} = :id RETURNING {$this->dataCol} into :data";
            break;
        default:
            $data = $sessionData;
            $sql = "UPDATE {$this->table} SET {$this->dataCol} = :data, {$this->lifetimeCol} = :expiry, {$this->timeCol} = :time WHERE {$this->idCol} = :id";
            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