This is an outdated version. Please see the newer version here.
DataMapper OverZealous Edition 1.6.2
Download the Latest Version Here
View the change log and the upgrade process
Having issues? Please look through the Troubleshooting Guide & FAQs
View the Complete Manual
Search the Manual NEW!
(Due to the server’s caching configuration, you may need to forcibly refresh your browser to see the changes in the manual.)
DataMapper (DM) is an Object-Relational Mapper that builds on ActiveRecord. Data is loaded from database tables into objects, and relationships can be managed through simple, easy-to-read functions.
DataMapper OverZealous Edition (DMZ) adds several important features to DM, enhancing it’s usage, usually without requiring any code changes.
To install DMZ over DataMapper, the (fairly simple) upgrade process is described here.
DMZ offers these features and more over the original DataMapper:
• In-table foreign keys
• Multiple relationships to the same model
• Better self references
• Add fields from a related model into one query
• Update, view, and query extra columns on join tables
• The ability to generate and use subqueries
• A shareable extension mechanism, including:
• Easy creation of HTML forms,
• Processing posted input,
• Converting to-and-from JSON, CSV, and arrays, and
• Query caching
NOTE: 1.6.2 includes a minor bugfixes. There are no changes to the core DMZ library.
If you are upgrading from 1.5.x or earlier, this is a major change. There is a good chance DMZ 1.6 could break existing code.
The major changes in this version revolve around the db object. Previously, a single DataBase object was created for the entire application. Changes to any $object->db would affect all other objects, widgets, and whatevers.
DMZ 1.6 introduces a dynamically created DB object. A new one is created every time a query is needed. There are several important reasons for this:
1. Multiple queries can be built simultaneously. If one large query is being built, and needs the results of a different query, it is safe to build, run, and process a second query, without affecting the original.
2. The multiple query functionality makes it possible to create subqueries using the existing Active Record methods. This is very powerful, as you can build the query on the other object, then easily include it in your main query.
3. Subqueries allow DMZ to calculate and include the number of related objects along-side the main object being queried.
4. While not tested, it should be easier that ever to work with multiple databases simultaneously. (You won’t be able to query across them, but no more hacking to get a different DB for different objects!) See db_params on this page.
The dynamic DB can be disabled, but all of the above will no longer work.
Besides this, DMZ 1.6 includes several other new features:
• SQL Functions and expressions can be built using AR-like methods, as well as used in SELECT and query statements.
• You can get the text of a query without running it using get_sql.
• There is a new virtual validation rule, always_validate, that can be used to override the default behavior of ignoring non-required empty fields.
Thanks goes to stensi, for providing such an amazing code base to work on.