added getLongestEntry

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-01-25 20:35:49 +01:00
parent 35ae3c4505
commit 1bd36ce6fd

View File

@ -178,4 +178,24 @@ class NameserverController
exit($e->getMessage());
}
}
/**
* @param String $field
*
* @return int
*/
public function getLongestEntry(String $field): int
{
$statement = "
SELECT MAX(LENGTH(" . $field . ")) as length FROM " . DatabaseConnection::TABLE_NAMESERVERS;
try {
$statement = $this->databaseConnection->getConnection()->prepare($statement);
$statement->execute();
$result = $statement->fetch();
return $result['length'];
} catch (PDOException $e) {
exit($e->getMessage());
}
}
}