DB_DataContainer Publisher's description
from Mika Tuupola
DB_DataContainer is a PEAR compliant database persistence layer and data encapsulation class.
DB_DataContainer is a PEAR compliant database persistence layer and data encapsulation class. A persistence layer can encapsulate the behaviour needed to make objects persistent like for exemple: to load, save and delete objects to and from persistent storage. Currently the only supported persistence mechanisms are relational databases. Database abstraction is provided by PEAR DB.
Data encapsulation is provided by overloaded accessor methods. This means that if you have a property named $foo and you do not write getFoo() and setFoo() methods in the extending class yourself, they will be automatically provided by DB_DataContainer.
As a result of the provided persistence mechanism and data encapsulation DB_DataContainer together with few lines of extra code can be used to implement the Active Record Pattern as described by Martin Fowler:
An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
The class does not use any external configuration files. The extending class itself IS the configuration. All you need to take care about is to have matching propertyname - columname pairs in the class and the database table.
If your database schema changes, for example you add an column foo to the table, all you need to do is to add a property name foo to your class which extends DB_DataContainer. There is no need to rewrite any internal SQL queries.
The class does not provide direct support for JOIN:s or table linking. For extreme cases it is still possible to pass hardcoded SQL queries. This usage is discouraged since it breaks the basic idea of using DB_DataContainer.
Here are some key features of "DB DataContainer":
??? Simple API
??? Persistence mechanism encapsulation. You only need to call load(), save() or delete(). Note that there are no separate methods for INSERT and UPDATE. save() figures itself out which query to use.
??? Overloaded accessor methods for class properties without such methods.
What's New in This Release:This release fixes problems with protected and private data members when using PHP5.
System Requirements:This release fixes problems with protected and private data members when using PHP5.
Program Release Status: Minor Update
Program Install Support: Install and Uninstall