From b7df1220fba8362429085629004c843d9084c69c Mon Sep 17 00:00:00 2001 From: tracer Date: Sun, 23 Jan 2022 16:32:22 +0100 Subject: [PATCH] added getLongest entry Signed-off-by: tracer --- bindAPI/src/Controller/PanelController.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bindAPI/src/Controller/PanelController.php b/bindAPI/src/Controller/PanelController.php index baa4c5f..6a15c3f 100644 --- a/bindAPI/src/Controller/PanelController.php +++ b/bindAPI/src/Controller/PanelController.php @@ -181,4 +181,24 @@ class PanelController } } + + /** + * @param $id + * + * @return int + */ + public function getLongestEntry(String $field): int + { + $statement = " + SELECT MAX(LENGTH(" . $field . ")) as length FROM " . DatabaseConnection::TABLE_PANELS; + + try { + $statement = $this->databaseConnection->getConnection()->prepare($statement); + $statement->execute(); + $result = $statement->fetch(); + return $result['length']; + } catch (PDOException $e) { + exit($e->getMessage()); + } + } } \ No newline at end of file