From f7e49e67a0c7fc0f22432c2944c5a29775a80833 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 31 Mar 2022 14:33:03 +0200 Subject: [PATCH] Add function for getting time IDs by their logged import concordances --- src/NodaIDGetter.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/NodaIDGetter.php b/src/NodaIDGetter.php index 9d8031f..5a776ab 100644 --- a/src/NodaIDGetter.php +++ b/src/NodaIDGetter.php @@ -430,4 +430,38 @@ final class NodaIDGetter { return $output; } + + /** + * Returns time ID by entry in time translations table. + * + * @param MDMysqli $mysqli_noda Database connection. + * @param string $instance Instance in which the import was run. + * @param integer $institution_id ID of the importing institution. + * @param string $name Name of the time to search for. + * + * @return integer + */ + public static function getTimeIDByImportLog(MDMysqli $mysqli_noda, string $instance, int $institution_id, string $name):int { + + if (empty($name)) return 0; + + $timeByImportLogResult = $mysqli_noda->query_by_stmt(" + SELECT `zeit_id` + FROM `zeiten_logged_imports` + WHERE `instance` = ? + AND `institution_id` = ? + AND `input_string` = ? + LIMIT 2", "sis", $instance, $institution_id, $name); + + if ($timeByImportLogData = $timeByImportLogResult->fetch_row()) { + $output = $timeByImportLogData[0]; + } + else $output = 0; + + $timeByImportLogResult->close(); + $timeByImportLogResult = null; + + return $output; + + } }