diff --git a/src/NodaIDGetter.php b/src/NodaIDGetter.php index a865209..4aafa6f 100644 --- a/src/NodaIDGetter.php +++ b/src/NodaIDGetter.php @@ -704,6 +704,37 @@ final class NodaIDGetter { } + /** + * Returns time ID by entry in time name rewriting table. + * + * @param MDMysqli $mysqli_noda Database connection. + * @param string $lang Language to check in. + * @param string $name Name of the time to search for. + * + * @return array + */ + public static function getTimeIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):array { + + if (empty($name)) return []; + + $output = []; + + $timeRewriteResult = $mysqli_noda->query_by_stmt(" + SELECT `zeit_id` + FROM `zeit_rewriting` + WHERE `language` = ? + AND `input_name` = ?", "ss", $lang, $name); + + while ($timeRewriteData = $timeRewriteResult->fetch_row()) { + $output[] = $timeRewriteData[0]; + } + + $timeRewriteResult->close(); + + return $output; + + } + /** * Returns time ID by base name. * @@ -911,6 +942,10 @@ final class NodaIDGetter { return $timeIdByName; } + if (!empty($timeIdByRewrite = self::getTimeIDByRewrite($mysqli_noda, $lang, $name))) { + return end($timeIdByRewrite); + } + if ($instance !== "") { if (($timeIdByImportLog = self::getTimeIDByImportLog($mysqli_noda, $instance, $institution_id, $name)) !== 0) { return $timeIdByImportLog;