DataMapper


Get Copy

Get Copy returns a copy of the object. This is essentially a clone of the object but with the ID cleared. It can allow you to quickly save a new record of an existing similar item. For example:

// Let's save a new hosting plan
$p = new Plan();

$p->name = 'The 100GB Plan';
$p->storage = 1000;
$p->bandwidth = 2000;
$p->databases = 5;
$p->domains = 5;
$p->emails = 50;

$p->save();

// Now, lets make a copy of that saved plan and base a new one off of it
$p = $p->get_copy();

// Change only what we need to
$p->name = 'The Big 150GB Plan';
$p->storage = 1500;
$p->bandwidth = 2500;

// And now save a new record
$p->save();