Closed vmhnrj closed 10 years ago
I am not sure I see why this is needed. The "is new" status is handled for you internally by the ORM model.
It's even a bad idea for Model_Crud.
If you fetch a record, then flip the is_new flag, then save it, it crashes with a "duplicate key" exception. This is exactly what ORM wants to avoid.
If you need an ORM object with existing data in a new state (for example because you want to copy it), simply clone the object. That will not only reset the is_new state, but some other internal structures as well.
is_new() is needed when we want to decide, whether this object is from Existing DB record, or a newly created object. This is may not be required for all scenarios, but at the end of code when developer wants to take a decision, it may be required.
Yes, I know what it does. But the Orm model will take care of that. Either it's loaded from the DB, and then it is not new, or it's loaded by code, and then it is new. And there isn't any other option. And the way to change a DB loaded object to new, the correct way to do that is to clone it. If you're doing something else, chances are you're doing it wrong.
So you really have to come up with a valid use-case of us to consider changing it.
Unlike Model::crud::is_new(), there is no set method for Orm Object. Model::crud::is_new(false) -- works well, but not in Orm Object. please fix in next release.