Add function to get tag IDs by their translated names

This commit is contained in:
Joshua Ramon Enslin 2020-12-07 13:43:07 +01:00
parent 50ff1a2339
commit ca13f36c0d
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -10,7 +10,6 @@ declare(strict_types = 1);
* Contains static functions for getting IDs for noda entries by various means.
*/
final class NodaIDGetter {
/**
* Returns persinst ID by entry in persinst name rewriting table.
*
@ -171,6 +170,70 @@ final class NodaIDGetter {
}
/**
* Returns tag ID by entry in tag translations table.
*
* @param MDMysqli $mysqli_noda Database connection.
* @param string $lang Language to check in.
* @param string $name Name of the tag to search for.
*
* @return integer
*/
public static function getTagIDByTransName(MDMysqli $mysqli_noda, string $lang, string $name):int {
if (empty($name)) return 0;
$tagByTLNameResult = $mysqli_noda->query_by_stmt("
SELECT `tag_id`
FROM `tag_translation`
WHERE `trans_name` = ?
AND `trans_language` = ?
LIMIT 2", "ss", $name, $lang);
if ($tagByTlData = $tagByTLNameResult->fetch_row()) {
$output = $tagByTlData[0];
}
else $output = 0;
$tagByTLNameResult->close();
$tagByTLNameResult = null;
return $output;
}
/**
* Returns tag ID by entry in tag noda table.
*
* @param MDMysqli $mysqli_noda Database connection.
* @param string $noda_source Language to check in.
* @param string $noda_nrinsource Name of the tag to search for.
*
* @return integer
*/
public static function getTagIDByNodaLink(MDMysqli $mysqli_noda, string $noda_source, string $noda_nrinsource):int {
if (empty($noda_nrinsource)) return 0;
$tagByNodaResult = $mysqli_noda->query_by_stmt("
SELECT `tag_id`
FROM `noda_tag`
WHERE `noda_source` = ?
AND `noda_nrinsource` = ?
LIMIT 2", "ss", $noda_source, $noda_nrinsource);
if ($tagByNodaData = $tagByNodaResult->fetch_row()) {
$output = $tagByNodaData[0];
}
else $output = 0;
$tagByNodaResult->close();
$tagByNodaResult = null;
return $output;
}
/**
* Returns tag ID by entry in tag name rewriting table.
*
@ -202,5 +265,4 @@ final class NodaIDGetter {
return $output;
}
}