Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Using the DAO Generator for PHP and MySQL

Discover how to generate PHP classes that provide common MySQL database operations using the DAO design pattern.


advertisement

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

 
Figure 1. DAO Generator Architecture: The diagram shows the architecture and data flow for the 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:

  1. Download the phpdao-1.7.zip archive.
  2. Unzip the archive in the htdocs directory.
  3. Setup a connection to an existing database by specifying the database properties in the templates/class/dao/sql/ConnectionProperty.class.php file.
  4. Run the generate.php script.
  5. The tool places generated classes in the newly created folder named generated.

Figure 1 shows a diagram of the DAO generator for PHP and MySQL tool architecture.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap