Relational Model Documentation

$followers = $this ->add('Model_Book') ->ref('Author') ->ref('Followers') ->dsql()->field('count(*)') ->getOne();

Active Record (ORM) with support for Conditions, Expressions, Sub-Queries, References and Joins. Based on "Model" and "DSQL".

Documentation:

Goals and Features of Model

Eliminate the need to write any queries

Models will manage your SQL Query for you, consistently and reliably.

Automatic Conditions

When traversing references, conditions are automatically set eliminating the possibility for developer's mistake.

Complex Table Joins

Sometimes your business entity consists of 2, 3 or even more tables joined together. Relational Models support automatic table joins when you are retrieving data or inserts into related table and linking ID fields if you are addin records.

Expressions

Models do eliminate need for the SQL but they still give the power of specifying expressions.

Based on Basic Models

Because Model_Table inherits regular Model, you can still use it with any Data Controllers such as caches.

Multi-row Acitons

Whenever you need to create a custom SQL query, you can clone it off "base" query used by the model. That will automatically apply conditions and joins.

Insert versus Modify

Relational Models distinguish events for performing Insert and Modification. You can set hooks to intercept and modify query before it is executed.

Relies on DSQL

Through the power of DSQL Models support multiple database vendors and will automatically use proper SQL syntax.

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: No attempting to manage structure

That is job of your database migration scripts.

Not Limiting

Relational Model does not take the power of custom SQL queries.

Suggest a Resource