I recently gave myself the challenge of developing a web front-end to my work’s CRM system (Customer Relationship Management). Seemed straightforward enough. However the CRM system in question was written at least a decade ago with technologies which are no longer being maintained. The underlying database FireBird SQL (formally Borland InterBase), may have been a good in its hay day but is no contender amongst MySQL, SQL Server, or MSSQL Server, given the support available from vendors and the community.
I am also a big proponent of CakePHP, an easy to learn and simple MVC framework for PHP. One of the big advantages of CakePHP is its excellent object relational mapping (ORM) – the ability to represent objects and relationships contained within a database natively in your application code. I only have to tell CakePHP the name of the table and it will happily work out the schema using a bit of reflection.
I wanted this convenience in creating my front-end to my CRM, however as of version 2.0+, CakePHP no longer natively supports these
minority databases. They do however still maintain their datasources plugin which does incorporate the FireBird SQL datasource although this is only compatible up to version 1.3 of CakePHP.
After searching the internet for a decent walk through or tutorial, I came up with very little and so I decided to collate what have learned in this post with the hope that someone else can benefit from it.
Firstly you will need to obtain the datasources plugin from github and stick it in your application’s plugin folder (app/plugins) – make sure you get the master branch and not the 2.0 as it needs to be compatible with your version of CakePHP (1.3 ideally)
The next thing you need to do is edit the databases config file (app/config/database.php):
var $default= array( 'driver' => 'Datasources.DboFirebird', //references the datasources plugin 'persistent' => false, 'host' => 'localhost', //the host name of your database 'login' => 'sysdba', 'password' => 'masterkey', 'database' => 'C:\\path\\to\\database.gdb', //path to the database - note the double backslashes 'prefix' => '', //'encoding' => 'utf8', );
The two important things you should note of is the driver key-value pair which references the datasource plugin namespace, and secondly the double backslashes for the database file path.
All the models you create for your application should now access the corresponding tables through the FireBird SQL connection.