Add functions to get actor and place IDs by import logs

This commit is contained in:
Joshua Ramon Enslin 2021-01-04 22:50:26 +01:00
parent 8f612dede1
commit 9f67d253da
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -74,6 +74,43 @@ final class NodaIDGetter {
}
/**
* Returns persinst ID by entry in persinst 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 persinst to search for.
* @param string $birthYear Year of birth. Optional.
* @param string $deathYear Year of death. Optional.
*
* @return integer
*/
public static function getPersinstIDByImportLog(MDMysqli $mysqli_noda, string $instance, int $institution_id, string $name, string $birthYear = "", string $deathYear = ""):int {
if (empty($name)) return 0;
$lookUpName = $name . $birthYear . $deathYear;
$persinstByImportLogResult = $mysqli_noda->query_by_stmt("
SELECT `persinst_id`
FROM `persinst_logged_imports`
WHERE `instance` = ?
AND `institution_id` = ?
AND `input_string` = ?
LIMIT 2", "sis", $instance, $institution_id, $lookUpName);
if ($persinstByImportLogData = $persinstByImportLogResult->fetch_row()) {
$output = $persinstByImportLogData[0];
}
else $output = 0;
$persinstByImportLogResult->close();
$persinstByImportLogResult = null;
return $output;
}
/**
* Returns place ID by entry in place name rewriting table.
*
@ -170,6 +207,40 @@ final class NodaIDGetter {
}
/**
* Returns place ID by entry in place 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 place to search for.
*
* @return integer
*/
public static function getPlaceIDByImportLog(MDMysqli $mysqli_noda, string $instance, int $institution_id, string $name):int {
if (empty($name)) return 0;
$placeByImportLogResult = $mysqli_noda->query_by_stmt("
SELECT `ort_id`
FROM `orte_logged_imports`
WHERE `instance` = ?
AND `institution_id` = ?
AND `input_string` = ?
LIMIT 2", "sis", $instance, $institution_id, $name);
if ($placeByImportLogData = $placeByImportLogResult->fetch_row()) {
$output = $placeByImportLogData[0];
}
else $output = 0;
$placeByImportLogResult->close();
$placeByImportLogResult = null;
return $output;
}
/**
* Returns tag ID by entry in tag translations table.
*