<?php
var_dump(version_compare('10.0.', '10', '>='));
var_dump(version_compare('9.9.0', '10', '>='));
var_dump(version_compare('9', '10', '>='));
var_dump(version_compare('10.0.1', '10', '>='));
switch ('sqlsrv') {
case 'mysql':
echo "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
echo "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, $this->timeCol = :time";
case 'sqlsrv' && version_compare('10.0', '10', '>='):
// MS SQL Server requires MERGE be terminated by semicolon
echo "MERGE";
case 'sqlite':
echo "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)";
}
preferences:
31.6 ms | 402 KiB | 5 Q