select /**/ from `object_log`
join (
select max(id) as id
from `object_log`
group by `id_gsm`
) lastevents using(id)
ORDER BY `id_gsm` ASC
Persistent connections were designed to have one-to-one mapping to regular connections. That means that you should always be able to replace persistent connections with non-persistent connections, and it won't change the way your script behaves. It may (and probably will) change the efficiency of the script, but not its behavior!
<option value="1" <?= $data['active'] ? ' selected="selected":'''?>>Активен</option>
<option value="0" <?= !$data['active'] ? ' selected="selected":'''?>>Не активен</option>