4 ms·
How about a compromise? IDB is what gets passed to stuff. Singleton::DB implements IDB, and the PHP page code passes DB::GetInstance() to the functions that t
by breckinloggins 15y ago
How about a compromise? IDB is what gets passed to stuff. Singleton::DB implements IDB, and the PHP page code passes DB::GetInstance() to the functions that take IDB.
- AndrewDucker 15y agoYup, that works. Or the functions check to see if they've been passed something, and if not then they use the singleton. So long as you can choose when to call it with an actual database link, and when to call it with a fake one your code is all perfectly testable.