From 7ff986bdd874e352d1874dc9c093d1ac128c25db Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sat, 16 Apr 2022 23:05:36 +0200 Subject: [PATCH] Add function getPersinstIDByNodaLink for getting actor IDs by their noda IDs in NodaIDGetter --- src/NodaIDGetter.php | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/NodaIDGetter.php b/src/NodaIDGetter.php index 5a776ab..5ffba87 100644 --- a/src/NodaIDGetter.php +++ b/src/NodaIDGetter.php @@ -74,6 +74,38 @@ final class NodaIDGetter { } + /** + * Returns place ID by entry in place noda table. + * + * @param MDMysqli $mysqli_noda Database connection. + * @param string $noda_source Language to check in. + * @param string $noda_nrinsource Name of the place to search for. + * + * @return integer + */ + public static function getPersinstIDByNodaLink(MDMysqli $mysqli_noda, string $noda_source, string $noda_nrinsource):int { + + if (empty($noda_nrinsource)) return 0; + + $result = $mysqli_noda->query_by_stmt(" + SELECT `persinst_id` + FROM `noda` + WHERE `noda_source` = ? + AND `noda_nrinsource` = ? + LIMIT 2", "ss", $noda_source, $noda_nrinsource); + + if ($data = $result->fetch_row()) { + $output = $data[0]; + } + else $output = 0; + + $result->close(); + $result = null; + + return $output; + + } + /** * Returns persinst ID by entry in persinst translations table. * @@ -225,8 +257,8 @@ final class NodaIDGetter { AND `noda_nrinsource` = ? LIMIT 2", "ss", $noda_source, $noda_nrinsource); - if ($placeByNodaData = $placeByNodaResult->fetch_row()) { - $output = $placeByNodaData[0]; + if ($data = $placeByNodaResult->fetch_row()) { + $output = $data[0]; } else $output = 0;