Add functions for getting main synonym in list of synonyms
This commit is contained in:
parent
05fb965d8c
commit
0b5d5bdd12
@ -117,4 +117,60 @@ final class NodaLinkedEntityGetter {
|
||||
return array_keys($output);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the main synonym of a tag (or the tag ID itself, if there are
|
||||
* no synonyms).
|
||||
*
|
||||
* @param MDMysqli $mysqli_noda DB connection.
|
||||
* @param integer $tag_id ID of the tag to check.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getMainTagSynonymId(MDMysqli $mysqli_noda, int $tag_id):int {
|
||||
|
||||
$result = $mysqli_noda->query_by_stmt("SELECT `tag_syn_main`
|
||||
FROM `tag_syn`
|
||||
WHERE `tag_syn_sub` = ?
|
||||
LIMIT 1", "i", $tag_id);
|
||||
|
||||
if ($cur = $result->fetch_row()) {
|
||||
$output = MD_STD_IN::sanitize_id($cur[0]);
|
||||
}
|
||||
else {
|
||||
$output = $tag_id;
|
||||
}
|
||||
$result->close();
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the main synonym of a place (or the place ID itself, if there are
|
||||
* no synonyms).
|
||||
*
|
||||
* @param MDMysqli $mysqli_noda DB connection.
|
||||
* @param integer $place_id ID of the place to check.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function getMainPlaceSynonymId(MDMysqli $mysqli_noda, int $place_id):int {
|
||||
|
||||
$result = $mysqli_noda->query_by_stmt("SELECT `ort_syn_main`
|
||||
FROM `ort_syn`
|
||||
WHERE `ort_syn_sub` = ?
|
||||
LIMIT 1", "i", $place_id);
|
||||
|
||||
if ($cur = $result->fetch_row()) {
|
||||
$output = MD_STD_IN::sanitize_id($cur[0]);
|
||||
}
|
||||
else {
|
||||
$output = $place_id;
|
||||
}
|
||||
$result->close();
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user