Database-Driver Support in Doctrine 2

Tags: doctrine2

Posted about 1 year ago by beberlei

Not only the ORM part of Doctrine will see major changes for the step from the 1.x to the Doctrine 2 series. The DBAL layer has undergone major refactorings and there has been a very throughout separation of concerns. Any database platform that will be supported has to extend four different classes/interfaces.

  • Doctrine\DBAL\Driver and Doctrine\DBAL\Driver\Statement - Both interfaces implement the interference between PHP and the Database, they are the lowest layer of any platform support.
  • Doctrine\DBAL\Platforms\AbstractPlaform - This abstract class requires you to specify the specialites of the SQL dialect of the database-platform you are going to implement.
  • Doctrine\DBAL\Schema\AbstractSchemaManager - This abstract class defines the interaction of the database platform to create a database schema, for example in combination with the ORM SchemaTool.

For the Doctrine 2.0 release we plan to support 4 different platforms, all tested in-depth:

  • MySQL using the PDO Mysql extension
  • PgSQL using the PDO PostgresSQL extension
  • Oracle using the OCI extension
  • Sqlite using the PDO SQLite extension

Both the SchemaManager and Platform can be re-used for any Driver that is connected to the database. If you would want to use Mysqli instead of PDO MySQL you would only need to implement a new Driver and Statement. And if you just want to change some of the sql specific details in regard to schema generation you would only need to extend the AbstractPlatform.

Still, from a database-platform point of view the default support is lacking, for example MsSql support with both PDO and SqlSrv is currently missing. Firebird or IBM Db2 are other platforms that are wide-spread and not supported currently. However we don't want to rush only half-finished support into Doctrine 2. That is where you come in: We would greatly appreciate any help in getting support for any new database platform into Doctrine 2.

For the implementation of a completly new database platform you can rely on the powerful PHPUnit Testsuite of Doctrine 2. There are lots of tests that check the functionality of your driver, platform and schema implementations against various scenarios. Additionally the complete ORM functional test-suite can run against your new database platform. Furthermore you can count of everyone in the Doctrine DEV Team for help, we are hanging around on Freenode IRC in the #doctrine-dev Channel. You could also create a ticket on Jira and attach a patch or just discuss your ideas.


Comments (6) [ add comment ]

Thumbs up for the testing approach alone! Posted by Christian about about 1 year ago.

The more I'm digging into the whole issue of testing the more I appreciate (apart from your obviously great achievements) a good test coverage! This definitely proves that Doctrine wants to stay in the business and continue to be a professional tool!

Thanks a lot!

Christian http://test.ical.ly

FIREBIRD Posted by Raphael about about 1 year ago.

Hello We need a PHP ORM for our database which is FIREBIRD. Do you have an idea when FIREBIRD will be supported by Doctrine 2 ? Is it useful to download an old version (1.1.6) of Doctrine ? Thanks.

ORM DB2 Posted by Raul Vera about about 1 year ago.

We can to connect with a DB2 Database over DBAL, but we want to manage all the ORM Mapping with DB2, we waiting that Doctrine and Symfony support that issue

Firebird Support Posted by srayner about 3 months ago.

+1 for Firebird.

I have legacy applications with a Firebird database back end. Currently i'm stuck with using Zend Db when it comes to Firebird compatability.

I too would like to see doctrine support Firebird. I think the problem might be that one one is activly developing the Firebird PDO driver for PHP 5.3

Firebird Support Posted by Jürgen about about 1 month ago.

I need Firebird support also.

Did there any plans or (better) results?

Thanks in advance.

Drivers Posted by Rodrigo about about 1 month ago.

MS SQL Server support?

Create Comment