Skip to content

Commit 05ea19a

Browse files
committed
[HttpFoundation] use MERGE SQL for MS SQL Server session storage
1 parent e58d7cf commit 05ea19a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,15 @@ private function getMergeSql()
227227
return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " .
228228
"ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)";
229229
case 'oci':
230+
// DUAL is Oracle specific dummy table
230231
return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) " .
231232
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " .
232233
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data";
234+
case 'sqlsrv':
235+
// MS SQL Server requires MERGE be terminated by semicolon
236+
return "MERGE INTO $this->table USING (SELECT 'x' AS dummy) AS src ON ($this->idCol = :id) " .
237+
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " .
238+
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data;";
233239
}
234240

235241
return null;

0 commit comments

Comments
 (0)