The entity.drop( ) method deletes the data contained in the entity from the datastore. The record referenced by the entity is also deleted from the related table. This entity method performs the same action as DELETE RECORD, with one notable difference: the deleted data remains in the memory and can still be referenced after deletion.
We can utilize this feature to help user needs review last change, or even recover deleted record. For example, the code below retrieves first record from the database as an entity, drop it, and restored it using the reference retained in memory:
Note $person is copied to $newPerson with object using toObject() and fromObject. If the refence of deleted $person is direct cloned to $newPerson, it will have the previous stamp, which will result a failure when trying to save $newPerson. In order to recreate a record with same primary key, the stamp needs to start from scratch.