If I forge and save an object that extends from Orm\Model, values that are populated by the database are not pulled back into the object (created_at, modified_at, etc). Is this normal? It's really screwing me up as I move from Model_Crud (reason for move is a couple of compound key tables). Is there any way to force this behavior? I'm on 1.7.1.
Neither Model_Crud nor ORM does a re-read of the record after a save. So (this is what I assume) if you use something like DEFAULT in a MySQL column, the default assigned value when you insert a new row will not be present in either of them?
Harro, I see now that you are right, my CRUD models allowed me to do this:
protected static $_mysql_timestamp = TRUE;
protected static $_created_at = 'created_at';
protected static $_updated_at = 'updated_at';
And populated the values for me. I moved these into properties, but couldn't have expressions in my static properties (eg. array('default'=>time()). Do I need to use observers to achieve the same thing here?
You can not have expressions in property definitions. If you have a need for them, define an _init() static method, and put the code to complete your definitions in there. We use it all the time, for example to populate option arrays (for dropdowns on forms), or to add language specific defaults.