From 2c6179914aa29c25f1692293983a129ddb708413 Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 23 Jan 2022 19:19:05 +0100 Subject: [PATCH] fixed error in check for exiting tables Signed-off-by: tracer --- bindAPI/src/Controller/DatabaseConnection.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bindAPI/src/Controller/DatabaseConnection.php b/bindAPI/src/Controller/DatabaseConnection.php index d0a5762..cffb748 100644 --- a/bindAPI/src/Controller/DatabaseConnection.php +++ b/bindAPI/src/Controller/DatabaseConnection.php @@ -30,7 +30,9 @@ class DatabaseConnection ); $sql = "SHOW TABLES"; $statement = $this->dbConnection->prepare($sql); - if (!$statement->execute()) { + $statement->execute(); + $result = $statement->fetch(); + if (empty($result)) { echo 'Error: Cannot find tables.' . PHP_EOL; if (confirm('Should I try to create them?')) {