About the connections created through classes
eg: db::SQL()->query();
then db::SQL()->lastInsertId();
it will create a new connection and will not return the last ID inserted. it is better to include a PDO connection file (or directly the logins) and work with it to get the last ID properly.
$db = new PDO(logins);
$db->query();
$db->lastInsertId();