From 7ef09db72c18f870ca363ed8f4781fa0bdee5abc Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 4 Jan 2021 23:06:36 +0100 Subject: [PATCH] Add static function in NodaIDGetter to get tag ID by import log --- src/NodaIDGetter.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/NodaIDGetter.php b/src/NodaIDGetter.php index 3651033..d45e933 100644 --- a/src/NodaIDGetter.php +++ b/src/NodaIDGetter.php @@ -336,4 +336,38 @@ final class NodaIDGetter { return $output; } + + /** + * Returns tag ID by entry in tag 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 tag to search for. + * + * @return integer + */ + public static function getTagIDByImportLog(MDMysqli $mysqli_noda, string $instance, int $institution_id, string $name):int { + + if (empty($name)) return 0; + + $tagByImportLogResult = $mysqli_noda->query_by_stmt(" + SELECT `tag_id` + FROM `tag_logged_imports` + WHERE `instance` = ? + AND `institution_id` = ? + AND `input_string` = ? + LIMIT 2", "sis", $instance, $institution_id, $name); + + if ($tagByImportLogData = $tagByImportLogResult->fetch_row()) { + $output = $tagByImportLogData[0]; + } + else $output = 0; + + $tagByImportLogResult->close(); + $tagByImportLogResult = null; + + return $output; + + } }