How to Create a Postgres and MySql Driver!!!!

The software that I write is not intended for just one customer who is locked into a single RDBMS. Instead it can be used by virtually any customer using the RDBMS of their choice. How is this possible? I deliberately designed and built my infrastructure around the 3 Tier Architecture which breaks down application code into three distinct areas of responsibility:

1. Presentation logic = User Interface, displaying data to the user, accepting input from the user.
2. Business logic = Business Rules, handles data validation and task-specific behaviour.
3. Data Access logic = Database Communication, constructing SQL queries and executing them via the relevant API.

It is only the Data Access layer which communicates with the database, therefore it should be possible to communicate with another database simply by changing the component which exists within this layer. I have already produced two versions of my Data Access Object for MySQL:
One for versions up to 4.0 which uses the original mysql_* functions.

Another for version 4.1 and above which uses the 'improved' mysqli_* functions.
The purpose of this article is to document my experiences while producing a DAO for a totally different RDBMS, in this case for PostgreSQL (version 8.0.3).


No comments: