Add function getPersinstIDByNodaLink for getting actor IDs by their noda

IDs in NodaIDGetter
This commit is contained in:
Joshua Ramon Enslin 2022-04-16 23:05:36 +02:00
parent 7dde870afb
commit 7ff986bdd8
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -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;