Recently we added models to our framework (over at work) And I wanted to put down some of the concepts we added..
We use these to track the changes. There are 2 types. Temporary (virtual) recoverypoints who only exist during the actual existance of the modelfactory. These are stored in the memory of our modelfactory (which builds, maintains models, datasources ,resultsets and recoverypoints) The other type is both stored in memory… and in database. These recoverypoints can be saved for later use.
Any change made that is saved using the ->save() or ->saveProperty() method results in a recoverypoint. The recoverypoint id is returned from this method.
After which the usre can recover to that recovery point on that object by using $model->recover($recoverypointid);
Cross database transactions.
Since datasources for our models are spread across databases and even servers we can’t rely on normal mysql transactions. But we have to have transactions.. In case that user creation didn’t go as smooth as it was meant to. We solve this by creating our own transaction system in our modelfactory. (since that has all the data.. it seemed like the right place to do this) Which allows us to do everything we want … and if it breaks half way through or at the end.. just recover it.
We built in triggers to make sure that when lets say a domain gets changed from type 1 to type 3 that certain processes are triggered and certain changes made.
Certain fields have encryption be it one way or two way. We added these to transform certain pieces of information in their proper form. Like for example a string in the database that is actually a CSV format. Which you want to use as an array. All reading and writing is passed through these functions
Autofill is used to generate new data like “created” dates on items or ip addresses.
And plenty more (will add more later)