and this is hard because?
use classes to manage your database calls, the sql queries tend to be the same, or even just have classes with function that can interpret your basic commands and then ask the right questions.
So your user logs in
you look at who they are
set the database flag to mysql, oracle, ...
then each time you need to hit the database call your database handler with the info you need and the database type and let it do the work.
a bit of coding to setup but once it's done it should be reusable.
last thing you want is the database logic in every script though.