DataMapper OverZealous Edition


Delete All

Delete All is used to delete all objects in an objects all list. It is basically quicker than looping through the all list yourself to delete each one. For example:

// Get a number of books from the year 2000
$b = new Book();
$b->where('year', 2000)->get();

// Loop through the all list and delete them one by one
foreach ($b->all as $book)
{
    $book->delete();
}

Instead just do this:

$b = new Book();
$b->where('year', 2000)->get();
$b->delete_all();

This is especially useful for deleting related items.