From 2b14563643f4c77be8e5a1cf7259587bb91092c7 Mon Sep 17 00:00:00 2001 From: Samuel Wolff Date: Mon, 15 Jan 2024 09:39:19 +0100 Subject: [PATCH] nextId --- Controller/BenutzerController.php | 8 ++++++++ Model/BenutzerModel.php | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Controller/BenutzerController.php b/Controller/BenutzerController.php index 1d6e02b..61f64e1 100644 --- a/Controller/BenutzerController.php +++ b/Controller/BenutzerController.php @@ -36,6 +36,14 @@ class BenutzerController return json_encode($data); } + + public function nextId() + { + $result = $this->db->nextId(); + + return json_encode($result); + } + } ?> \ No newline at end of file diff --git a/Model/BenutzerModel.php b/Model/BenutzerModel.php index 3431c4e..3356ce7 100644 --- a/Model/BenutzerModel.php +++ b/Model/BenutzerModel.php @@ -94,6 +94,26 @@ class BenutzerModel extends Database return $result; } + public function nextId() + { + + $pdo = $this->linkDB(); + + $sql = "SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'Benutzerkonto'; "; + + try { + $stmt = $pdo->prepare($sql); + $stmt->execute(); + } catch (\PDOException $e) { + return false; + } + + $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); + + return $result; + + } + }