/** * {@inheritdoc} */ public function write($id, $data) { $platform = $this->con->getDatabasePlatform(); // this should maybe be abstracted in Doctrine DBAL if ($platform instanceof MySqlPlatform) { $sql = "INSERT INTO {$this->tableName} (id, data, sess_time) VALUES (%1\$s, %2\$s, %3\$d) " . "ON DUPLICATE KEY UPDATE sess_data = VALUES(sess_data), sess_time = CASE WHEN sess_time = %3\$d THEN (VALUES(sess_time) + 1) ELSE VALUES(sess_time) END"; } else { $sql = "UPDATE {$this->tableName} SET sess_data = %2\$s, sess_time = %3\$d WHERE sess_id = %1\$s"; } try { $rowCount = $this->con->exec(sprintf($sql, $this->con->quote($id), $this->con->quote(base64_encode($data)), time())); if (!$rowCount) { // No session exists in the database to update. This happens when we have called // session_regenerate_id() $this->createNewSession($id, $data); } } catch (\PDOException $e) { throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); } return true; }
protected function convertResults($results, DomainBase $domain, CaseSensor $sensor) { return $domain->convertResults($results, $this->conn->getDatabasePlatform(), $sensor); }
public function update(\Closure $logger = null) { $queries = $this->getSchemaDiff()->toSaveSql($this->conn->getDatabasePlatform()); $this->executeQueries($queries, $logger); }