From d55361e29bb2cdc044f46a1ef466e330471d9176 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Wed, 18 Oct 2023 01:54:40 +0200 Subject: [PATCH] Add function to check if a time name is blacklisted --- src/NodaBlacklistedTerms.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/NodaBlacklistedTerms.php b/src/NodaBlacklistedTerms.php index 30fcee9..8736835 100644 --- a/src/NodaBlacklistedTerms.php +++ b/src/NodaBlacklistedTerms.php @@ -122,4 +122,31 @@ final class NodaBlacklistedTerms { return true; } + + /** + * Checks if a time name is blacklisted in the DB. + * + * @param MDMysqli $mysqli DB connection. + * @param string $lang The user's currently used language. + * @param string $name The name entered by the user. + * + * @return boolean + */ + public static function checkTimeBlacklistedInDb(MDMysqli $mysqli, string $lang, string $name):bool { + + $result = $mysqli->query_by_stmt("SELECT 1 + FROM `" . DATABASENAME_NODA . "`.`zeiten_blacklist` + WHERE `language` = ? + AND `zeit_name` = ? + LIMIT 1", "ss", $lang, $name); + + if ($result->num_rows === 0) { + $result->close(); + return false; + } + + $result->close(); + return true; + + } }