DataMapper


Get Clone

Get Clone returns a clone of the object.

Note:  PHP's clone function is only capable of performing a shallow clone of objects. DataMapper's clone process has been improved over the default to be slightly less shallow, so related objects of a clone are also clones rather than references.

// Get a user
$u = new User();
$u->get_by_id($id);

$clone = $u->get_clone();

Looking at the above, both the $clone and $u objects are identical except you can modify the data of one, without affecting the data stored in the other. Saving the objects will of course update the same record in the database.