data access object (DAO) provides an abstract interface to a database—giving developers access to common database operations without them having to know the database schema details—essentially, data access object separate the business logic and data tiers of an application. This separation is important, because these two important application tiers should know almost nothing about each other, and you can expect both to evolve frequently and independently. With DAO in place, changing business logic can use the same DAO interface, while changes to persistence logic does not affect DAO clients—as long as the interface remains correctly implemented.
The DAO generator for PHP and MySQL automates the process of creating DAO classes for MySQL databases. In this article, you’ll see how to:
- Install the DAO generator for PHP and MySQL
- Generate a DAO artifact using a given database (bookstore)
- Create an application using DAO generator tool and its factory classes
- Create a transaction spanning multiple SQL operations
- Add a custom DAO function to a generated class
DAO generator for PHP and MySQL
A DAO generator creates classes in a specific language, usually for a specific target database. You use the DAO generator for PHP and MySQL to generate PHP classes that query and update MySQL databases using the DAO design pattern. The tool is relatively simple to install and use, but to use it effectively, you need to know a little about the DAO mechanism.
You can download the DAO generator for PHP and MySQL here. To install it, follow these steps:
- Download the phpdao-1.7.zip archive.
- Unzip the archive in the htdocs directory.
- Setup a connection to an existing database by specifying the database properties in the templates/class/dao/sql/ConnectionProperty.class.php file.
- Run the generate.php script.
- The tool places generated classes in the newly created folder named generated.
- Source: www.devx.com
Comments Off on Using the DAO Generator for PHP and MySQL