Add function for getting time ID by stored rewrite
This commit is contained in:
		@@ -704,6 +704,37 @@ final class NodaIDGetter {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns time ID by entry in time name rewriting table.
 | 
			
		||||
     *
 | 
			
		||||
     * @param MDMysqli $mysqli_noda Database connection.
 | 
			
		||||
     * @param string   $lang        Language to check in.
 | 
			
		||||
     * @param string   $name        Name of the time to search for.
 | 
			
		||||
     *
 | 
			
		||||
     * @return array<integer>
 | 
			
		||||
     */
 | 
			
		||||
    public static function getTimeIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):array {
 | 
			
		||||
 | 
			
		||||
        if (empty($name)) return [];
 | 
			
		||||
 | 
			
		||||
        $output = [];
 | 
			
		||||
 | 
			
		||||
        $timeRewriteResult = $mysqli_noda->query_by_stmt("
 | 
			
		||||
            SELECT `zeit_id`
 | 
			
		||||
            FROM `zeit_rewriting`
 | 
			
		||||
            WHERE `language` = ?
 | 
			
		||||
                AND `input_name` = ?", "ss", $lang, $name);
 | 
			
		||||
 | 
			
		||||
        while ($timeRewriteData = $timeRewriteResult->fetch_row()) {
 | 
			
		||||
            $output[] = $timeRewriteData[0];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $timeRewriteResult->close();
 | 
			
		||||
 | 
			
		||||
        return $output;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns time ID by base name.
 | 
			
		||||
     *
 | 
			
		||||
@@ -911,6 +942,10 @@ final class NodaIDGetter {
 | 
			
		||||
            return $timeIdByName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!empty($timeIdByRewrite = self::getTimeIDByRewrite($mysqli_noda, $lang, $name))) {
 | 
			
		||||
            return end($timeIdByRewrite);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($instance !== "") {
 | 
			
		||||
            if (($timeIdByImportLog = self::getTimeIDByImportLog($mysqli_noda, $instance, $institution_id, $name)) !== 0) {
 | 
			
		||||
                return $timeIdByImportLog;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user