$book = $this->add('Model_Book')
Base Class for your Real-Life entities. For use with no-SQL Data Controllers. Implements active record. Compatible with most Views.
Model is a fundamental class in Agile Toolkit which introduces concept of a very basic Active Record mechanism. Models also hold meta-information about your entity fields such as types, captions, validation, etc
Goals and Features of Model
Objects in our life are hierarchical. Your database is not. Agile Toolkit models follow your business model and adapt your data-base.
Each field is defined through a "Field" object. Need more meta-information, properties or flexibility? Extend the Field class.
Models assume that controller is using one database at a time. Inside a database you may have multiple tables (or files). Inside each file you will have records identified by "ID" (or key)
After you create instance of a model, you can define few more fields if you need to.
You may load model through one Data Controller, save will use same controller by default. You can, however, use another controller with same model.
Models implement iterators and array access. That means you can access model properties as it would be array and you can traverse through records inside a foreach() loop.
You can't have multiple fields with the same name.
Models are great for either direct use or to be used by standard views. Some other controllers will accept models too.
Models use hooks allowing you to control loading / saving events
What DSQL is not?
In the spirit of Agile Toolkit — all of it's classes are strictly focused on a one simple task, without trying to do everything. Here are things which Model will not do and why:
Model is implemented in under 200 lines of PHP code. It is designed to be common lowest denominator for many views.
Model is designed to be simple. It does not support RDBMS features.
Model does not attempt to emulate SQL features such as offsets. That's job of a Controller to implement.