Skip to content

Commit

Permalink
Correct CREATE TABLE IF NOT EXISTS syntax for MSSQL (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Kaos committed Dec 4, 2023
1 parent 3ed1c0a commit 4bb5c8b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/PicoDb/Driver/Mssql.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function getLastId()
*/
public function getSchemaVersion()
{
$this->pdo->exec("CREATE TABLE IF NOT EXISTS [".$this->schemaTable."] ([version] INT DEFAULT '0')");
$this->pdo->exec("IF (OBJECT_ID('".$this->schemaTable."')) IS NULL CREATE TABLE [".$this->schemaTable."] ([version] INT DEFAULT '0')");

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

0 comments on commit 4bb5c8b

Please sign in to comment.