Setup ID getter by rewrite for tags to return arrays

Tag rewrites can now be set for multiple target tags.
This commit is contained in:
Joshua Ramon Enslin 2020-12-20 23:24:08 +01:00
parent fce933c12a
commit af454ec013
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -241,23 +241,23 @@ final class NodaIDGetter {
* @param string $lang Language to check in.
* @param string $name Name of the tag to search for.
*
* @return integer
* @return array<integer>
*/
public static function getTagIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):int {
public static function getTagIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):array {
if (empty($name)) return 0;
if (empty($name)) return [];
$output = [];
$tagRewriteResult = $mysqli_noda->query_by_stmt("
SELECT `tag_id`
FROM `tag_rewriting`
WHERE `tag_language` = ?
AND `input_name` = ?
LIMIT 1", "ss", $lang, $name);
AND `input_name` = ?", "ss", $lang, $name);
if ($tagRewriteData = $tagRewriteResult->fetch_row()) {
$output = $tagRewriteData[0];
while ($tagRewriteData = $tagRewriteResult->fetch_row()) {
$output[] = $tagRewriteData[0];
}
else $output = 0;
$tagRewriteResult->close();
$tagRewriteResult = null;