Rollback your previous query of a particular event If any of the listed query fails

CodeIgniter utilizes an approach to transactions that is very similar to the process used by the popular database class ADODB. We’ve chosen that approach because it greatly simplifies the process of running transactions. In most cases all that is required are two lines of code.

Traditionally, transactions have required a fair amount of work to implement since they demand that you keep track of your queries and determine whether to commit or rollback based on the success or failure of your queries. This is particularly cumbersome with nested queries. In contrast, we’ve implemented a smart transaction system that does all this for you automatically (you can also manage your transactions manually if you choose to, but there’s really no benefit).

example
$this->db->trans_start();
$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE)
{
        $this->db->trans_rollback();
}
else
{
        $this->db->trans_commit();
}
for refrence in codeigniter 3.0
http://www.codeigniter.com/userguide3/database/transactions.html
for refrence in codeigniter 2.2
http://www.codeigniter.com/userguide2/database/transactions.html

Comments

Popular posts from this blog

Enable the imap in support in xampp server