use portable PEAR DB quoting function instead of mysql one
use SQL LAST_INSERT_ID() instead of client APIs mysql_insert_id()

still not really portable, but now other databases can at least
wrap their SQL alternatives into a SQL function called LAST_INSERT_ID()
make mysql specific connect/setup stuff depend on DBTYPE setting