Kohana 3 ORM: constructor “after load”

asusernamej2

New Member
Is there any way in Kohana 3's ORM to run a chunk of code in a model, but only after that model has been loaded from the database? A simple example is a required has_one relationship.\[code\] ORM::factory('user')->where('name', '=', 'Bob')->find();\[/code\]Now what if all users have to have some other property, so if Bob doesn't exist, it will have to be created? Right now, in the place where this line is running, I'm checking for null primary key, and instructing the model to add that relationship if so. But is there any way to have it done by the model? The problem with the constructor is that models can be constructed empty just before being populated from the DB, as is visible in this example, so I don't want that.
 
Back
Top