0 FROM `ytkns_redirects` WHERE `redirect_name` = :subdomain '); $check->bindValue('subdomain', $subdomain); return $check->execute() ? (bool)$check->fetchColumn() : true; } public static function find(string $subdomain): ?ZoneRedirect { $find = DB::prepare(' SELECT `redirect_name`, `redirect_target` FROM `ytkns_redirects` WHERE `redirect_name` = :subdomain '); $find->bindValue('subdomain', $subdomain); $redirect = $find->execute() ? $find->fetchObject(self::class) : false; return $redirect ? $redirect : null; } public static function create(string $subdomain, string $target): void { $create = DB::prepare(' REPLACE INTO `ytkns_redirects` ( `redirect_name`, `redirect_target` ) VALUES ( :name, :target ) '); $create->bindValue('name', $subdomain); $create->bindValue('target', $target); $create->execute(); } public function execute(): void { http_response_code(301); header(sprintf('Location: %s', $this->redirect_target)); } }