Skip to content

Commit

Permalink
[HttpFoundation] use MERGE SQL for MS SQL Server session storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobion committed Apr 8, 2014
1 parent e58d7cf commit 05ea19a
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -227,9 +227,15 @@ private function getMergeSql()
return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " .
"ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)";
case 'oci':
// DUAL is Oracle specific dummy table
return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) " .
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " .
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data";
case 'sqlsrv':
// MS SQL Server requires MERGE be terminated by semicolon
return "MERGE INTO $this->table USING (SELECT 'x' AS dummy) AS src ON ($this->idCol = :id) " .
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " .
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data;";
}

return null;
Expand Down

0 comments on commit 05ea19a

Please sign in to comment.