Skip to content

Commit 00c3b4f

Browse files
committed
Fix: db->query() will silently ignore the SQL errors.
Use db->exec() to 'fail early'
1 parent 7e4b362 commit 00c3b4f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

simple-db-migrator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
require_once __DIR__ . "/../vendor/autoload.php";
1717

18-
// Load database credentials from database.php
18+
// Load database credentials from database.php
1919
// where $dbPass, $dbName, $dbHost, $dbUser are defined.
2020
include __DIR__ . "/../database.php";
2121

@@ -75,7 +75,7 @@ private function runSQLTransaction($sql)
7575

7676
$this->L->debug("Runing SQL");
7777
$this->L->debug($sql);
78-
return $this->db->query($sql);
78+
return $this->db->exec($sql);
7979
}
8080

8181
/*
@@ -222,7 +222,6 @@ public function runDown()
222222
$this->db
223223
->prepare("DELETE FROM db_migrations WHERE version = ?")
224224
->execute([$lastRanMigration]);
225-
226225
$this->L->warning("Rollback completed");
227226
}
228227
}

0 commit comments

Comments
 (0)