Can you really rollback a transaction once it has been commited? I request this because within the Datamapper documentation i begin to see the trans_begin() method, however i did not discover the trans_end() method. Codeigniter has got the trans_complete() method, and so i assumed Datamapper might have the identical method.

One factor I discovered interesting is this answer. Can there be anything much like a savepoint in Datamapper/Codeigniter?

http://datamapper.wanwizard.eu/pages/transactions.html

DataMapper handles transactions in greatly exactly as CodeIgniter does (read CodeIgniter Transactions), clearly since it uses exactly the same techniques! Really the only difference is that you will be calling the transaction techniques on your DataMapper objects.

Which means that rather than:

$this->db->trans_begin();

You'd use:

$my_datamapper_object->trans_begin();

Anything else, based on the Datamapper documentation, is just like Codeigniter when it comes to transactions. Should you consider the source code for that Datamapper library, you'll notice that all trans_*() calls are merely wrapper functions. Example:

// Datamapper.php 1.8.dev line 3975
/**
 * Trans Complete
 *
 * Complete a transaction.
 *
 * @return  bool Success or Failure
 */
public function trans_complete()
{
    return $this->db->trans_complete();
}

A trans_end() method doesn't appear in either Codeigniter or Datamapper. You'd use trans_start() and trans_complete() for automatic transactions, in order to give them a call by hand:

http://codeigniter.com/user_guide/database/transactions.html

Running Transactions By hand

If you'd like to operate transactions by hand that can be done as follows:

$this->db->trans_begin();

$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');

if ($this->db->trans_status() === FALSE)
{
    $this->db->trans_rollback();
}
else
{
    $this->db->trans_commit();
}

Just replace $this->db together with your Datamapper object. For instance.

$u = new User($id);
$u->trans_begin();
$u->name = 'Jorge';
$u->save();

if ($u->trans_status() === FALSE)
{
    $u->trans_rollback();
}
else
{
    $u->trans_commit();
}