Using getlastautoid() on db

Less hassle and hopefully more compatible.