Add functions to check for actor IDs by name while including their life dates
This commit is contained in:
parent
4496a35f5c
commit
d6c514c208
|
@ -40,6 +40,33 @@ final class NodaIDGetter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns persinst ID by name, checking the different options for it.
|
||||
*
|
||||
* @param MDMysqli $mysqli_noda Database connection.
|
||||
* @param string $lang Language to check in.
|
||||
* @param string $name Name of the persinst to search for.
|
||||
* @param string $birth Birth year.
|
||||
* @param string $death Death year.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getPersinstIDByNamePlusYears(MDMysqli $mysqli_noda, string $lang, string $name, string $birth, string $death):int {
|
||||
|
||||
if (empty($name)) return 0;
|
||||
|
||||
if ($persinstByTransName = self::getPersinstIDByTransNamePlusYears($mysqli_noda, $lang, $name, $birth, $death)) {
|
||||
return $persinstByTransName;
|
||||
}
|
||||
|
||||
if ($persinstByBaseName = self::getPersinstIDByBaseNamePlusYears($mysqli_noda, $name, $birth, $death)) {
|
||||
return $persinstByBaseName;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns persinst ID by entry in persinst name rewriting table.
|
||||
*
|
||||
|
@ -102,6 +129,43 @@ final class NodaIDGetter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns persinst ID by entry in persinst translations table
|
||||
* plus birth and death.
|
||||
*
|
||||
* @param MDMysqli $mysqli_noda Database connection.
|
||||
* @param string $lang Language to check in.
|
||||
* @param string $name Name of the persinst to search for.
|
||||
* @param string $birth Birth year.
|
||||
* @param string $death Death year.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getPersinstIDByTransNamePlusYears(MDMysqli $mysqli_noda, string $lang, string $name, string $birth, string $death):int {
|
||||
|
||||
if (empty($name)) return 0;
|
||||
|
||||
$persinstByTLNameResult = $mysqli_noda->query_by_stmt("
|
||||
SELECT `persinst_translation`.`persinst_id`
|
||||
FROM `persinst_translation`, `persinst`
|
||||
WHERE `persinst_translation`.`persinst_id` = `persinst`.`persinst_id`
|
||||
AND `trans_name` = ?
|
||||
AND `trans_language` = ?
|
||||
AND `persinst_geburtsjahr` = ?
|
||||
AND `persinst_sterbejahr` = ?
|
||||
LIMIT 2", "ssss", $name, $lang, $birth, $death);
|
||||
|
||||
if ($persinstByTlData = $persinstByTLNameResult->fetch_row()) {
|
||||
$output = $persinstByTlData[0];
|
||||
}
|
||||
else $output = 0;
|
||||
|
||||
$persinstByTLNameResult->close();
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns persinst ID by base name.
|
||||
*
|
||||
|
@ -133,6 +197,43 @@ final class NodaIDGetter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns persinst ID by base name.
|
||||
*
|
||||
* @param MDMysqli $mysqli_noda Database connection.
|
||||
* @param string $name Name of the persinst to search for.
|
||||
* @param string $birth Birth year.
|
||||
* @param string $death Death year.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getPersinstIDByBaseNamePlusYears(MDMysqli $mysqli_noda, string $name, string $birth, string $death):int {
|
||||
|
||||
if (empty($name)) return 0;
|
||||
|
||||
$persinstByBaseNameResult = $mysqli_noda->query_by_stmt("
|
||||
SELECT `persinst_id`
|
||||
FROM `persinst`
|
||||
WHERE (
|
||||
`persinst_anzeigename` = ?
|
||||
OR `persinst_name` = ?
|
||||
OR CONCAT(`persinst_name`, ' (', `persinst_geburtsjahr`, '-', `persinst_sterbejahr`, ')') = ?
|
||||
)
|
||||
AND `persinst_geburtsjahr` = ?
|
||||
AND `persinst_sterbejahr` = ?
|
||||
LIMIT 2", "sssss", $name, $name, $name, $birth, $death);
|
||||
|
||||
if ($persinstByBaseData = $persinstByBaseNameResult->fetch_row()) {
|
||||
$output = $persinstByBaseData[0];
|
||||
}
|
||||
else $output = 0;
|
||||
|
||||
$persinstByBaseNameResult->close();
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns place ID by entry in place noda table.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user