From 54a30e683e7fb880244ac79f65e4cbd6c8326aa6 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 13 Nov 2023 00:11:56 +0100 Subject: [PATCH] Add class for loading info from distinctly_typed_strings table --- src/NodaDistinctlyTypedStrings.php | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/NodaDistinctlyTypedStrings.php diff --git a/src/NodaDistinctlyTypedStrings.php b/src/NodaDistinctlyTypedStrings.php new file mode 100644 index 0000000..aef90f2 --- /dev/null +++ b/src/NodaDistinctlyTypedStrings.php @@ -0,0 +1,44 @@ +query_by_stmt("SELECT `type` + FROM `distinctly_typed_strings` + WHERE `input_string` = ? + AND `language` = ?", "ss", $search_term, $lang); + + if (!($cur = $result->fetch_row())) { + $result->close(); + return ''; + } + $result->close(); + + if (!in_array($cur[0], ['persinst', 'zeiten', 'orte', 'tag', ''], true)) { + throw new Exception("Distinctly typed string of unknown type: " . $cur[0]); + } + + return $cur[0]; + + } + +}