I don't think it is a bad approach, but you may be able to make the code easier to read by breaking it up... but honestly if it isn't broke don't fix it. I feel like it would be easier to translate the code to mysqli if you weren't also trying to change the structure at the same time.