Skip to content

Commit 4bb5c8b

Browse files
authored
Correct CREATE TABLE IF NOT EXISTS syntax for MSSQL (#26)
1 parent 3ed1c0a commit 4bb5c8b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/PicoDb/Driver/Mssql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function getLastId()
135135
*/
136136
public function getSchemaVersion()
137137
{
138-
$this->pdo->exec("CREATE TABLE IF NOT EXISTS [".$this->schemaTable."] ([version] INT DEFAULT '0')");
138+
$this->pdo->exec("IF (OBJECT_ID('".$this->schemaTable."')) IS NULL CREATE TABLE [".$this->schemaTable."] ([version] INT DEFAULT '0')");
139139

140140
$rq = $this->pdo->prepare('SELECT [version] FROM ['.$this->schemaTable.']');
141141
$rq->execute();

0 commit comments

Comments
 (0)