MySQL PDO wrapper function with some debugging and timing functionality etc.