Welcome Guest, Not a member yet? Register   Sign In
Transactions in Codeigniter
#1

[eluser]bleu[/eluser]
Can I use transaction statements in controller as I need to run one query then another one which will retrieve data use that retrieved data to insert with another query.

I need all this in transactions.

How can I achieve that.

Will something like the below example work in model or do I need to use the combination of controller and model.


Code:
$this->db->trans_begin();

$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY to retrieve data...');

run data in loop create variables and insert in below query

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

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


Messages In This Thread
Transactions in Codeigniter - by El Forum - 04-10-2012, 11:40 PM
Transactions in Codeigniter - by El Forum - 04-11-2012, 03:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB