update database queries to use the new database class
Add tep_db_perform() equivalent
Register a shutdown function to close the session instead of closing it in the tep_redirect() function