Database Abstraction

Here at ireckon we've invested a lot of time into developing our own in-house PHP framework, dubbed Vincent. The need for a custom PHP framework arose after tests of existing frameworks (Zend, Symphony, CakePHP) failed on our existing server set up combined with the traffic that we currently do.

The intention was to write a lightweight framework that delivered as much of the functionality of the aforementioned bigger frameworks. The exercise has been a great success and what we've managed to create is a framework that both provides great support to developers while delivering on the promise of improved performance especially under load.

However, Vincent was originally created with a custom written database abstraction framework, dubbed Jules, but after a short period of time it became evident that Jules was not delivering any improvements over some of the existing technologies, especially considering the amount of time that would need to be invested in order to provide a database abstraction framework that was feature rich enough.

When it comes to any database framework there is only one main goal – provide a level of abstraction above the database that allows developer's to program without having to directly query the database. The other side effect of a good database framework is that changes to the underlying database structure and in some extent even the database technology in use requires minimal code changes, thus creating a more agile and rapid development environment.

So recently we've begun using Doctrine in our Vincent applications and the results have been very pleasing. Doctrine is arguably the most popular if not the best database application for PHP currently available and it provides both an object relational mapper (ORM) and a database abstraction layer (DBAL). The combination of both a DBAL and ORM means that as developers we can interact with the database by simply constructing objects in a typical object oriented (OO) manner and need not interact with the database directly.

Of course, to make these objects and Doctrine interact correctly with the database you are required to write a set of schema objects matching each of the tables in your database. Fortunately Doctrine is there to help and provides a method of creating the necessary schema objects by connecting to the database and analysing the current structure. Alternatively it can also create these files from YAML schema files.

The downside to any database framework is that the abstraction layer is often not as efficient as a developer can be especially when it's necessary to retrieve a complex set of object relations. However, Doctrine also provides a solution to this through it's Doctrine Query Language (DQL) that allows you to structure your queries through an OO style query interface.

Database abstraction layers provide a great level of support for developers but more importantly – for ireckon and our customers it means applications that are developed faster and that have a greater ability to adjust to your needs, essentially providing much more “bang for your buck”. Perhaps the most exciting thing is that we've really only had to scratch the surface of what Doctrine and Vincent can do for us and our customers, and there is plenty more to come.

About Jared

Jared has over 10 years experience developing applications for the web. He can often be found in a dimly light room with the music blasting hacking away at a project to the early hours of the morning.

Speak Your Mind

*