Data Access Objects Generator for PHP

As part of another open-source project which I recently (as of Aug, 2010) have been developing, I put together a nice Data Access Object generator for PHP. The project is called “phpdaogen”.

This DAO generator is BSD-licensed, and includes a PHP PreparedStatement implementation which does not use mysqli (which is unstable and tends to crash).

The nice thing about this DAO implementation is that with the PreparedStatement, you have the option of either using or not using the DAO implementation for one-off queries. DAO can be limiting for complex queries, so having the availability of PreparedStatement for application use can be a big plus.

DAO is very convenient for transactional processes and CRUD pages. I find it saves me a LOT of time and code over writing individual SQL statements to insert, update and delete rows. It’s much easier to deal with PHP data objects than to worry about interfacing to an SQL database. Phgpdaogen hides the SQL from the application when desired, but allows you to use SQL when it’s more convenient (for example, in search queries and reports which tend to have a one-to-one correspondence between an SQL table and a data table in the user interface).

The generator is a simple PHP script which reads your MySQL schema and generates two PHP classes per table: one DAO class, and one data object class.

If you’re a LAMP developer, this project can save you a lot of time. Download it and start using it today!

Phpdaogen is licensed under the BSD license, and can be downloaded from here: Data Access Objects (DAO) for PHP

UPDATE: phpdaogen has now been superseded by pdo-schema, which sits on top of PHP PDO. However, I would consider even this project obsolete in favor of the Illuminate/Eloquent ORM which is used in the Laravel framework and others.  It’s a stand-alone ORM which is quite functional and performant.

Leave a Reply

Your email address will not be published. Required fields are marked *