Add function to check if a time name is blacklisted

This commit is contained in:
Joshua Ramon Enslin 2023-10-18 01:54:40 +02:00
parent 37715bc3e8
commit d55361e29b
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -122,4 +122,31 @@ final class NodaBlacklistedTerms {
return true;
}
/**
* Checks if a time name is blacklisted in the DB.
*
* @param MDMysqli $mysqli DB connection.
* @param string $lang The user's currently used language.
* @param string $name The name entered by the user.
*
* @return boolean
*/
public static function checkTimeBlacklistedInDb(MDMysqli $mysqli, string $lang, string $name):bool {
$result = $mysqli->query_by_stmt("SELECT 1
FROM `" . DATABASENAME_NODA . "`.`zeiten_blacklist`
WHERE `language` = ?
AND `zeit_name` = ?
LIMIT 1", "ss", $lang, $name);
if ($result->num_rows === 0) {
$result->close();
return false;
}
$result->close();
return true;
}
}