Set_charset MYSQLI Commands out of sync?

There is such code, when I set the object encoding with charset set, then for any other query throws out the error "Commands out of sync". If you remove set the charset, it works, how to overcome the error?
$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();
}
July 9th 19 at 10:12
1 answer
July 9th 19 at 10:14

Find more questions by tags MySQLPHP