$db = Database::getInstance();
$mysqli = $db->getConnection();
$mysqli->set_charset('utf8');
$last_date = undef;
if ($stmt = $mysqli->prepare('select max(`date`) from `average_temp`')) {
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($last_date);
$stmt->fetch();
}