Documented query function in the database class, and added some sanity checking in usersettings.php