Creating Your Own Support for Multiple Databases
If you have a simple application that doesn't require complex database interaction, but you still want it to work with multiple databases, then you can create your own set of database wrapper functions.
You have to take into account the different database-specific limitations that may arise and code to the lowest common denominator. That is, you can't use the useful “AUTO_INCREMENT” column feature that is supported in MySQL if you also want to support MS SQL or PostgreSQL databases, since they do not implement that feature. Similarly, MySQL doesn't support secondary keys, so you cannot use that convention.
This next example provides a sample database wrapper that supports MySQL, MS SQL, and PostgreSQL ...
Get Advanced PHP for Web Professionals now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.