[eluser]mlakhara[/eluser]
I was trying to use the db class in codeigniter to implement a db transaction in which a row is updated and elements are selected and then prepped inorder to insert it in another table.
and then I had a doubt which I would like your help to clear it for me.
Can I do some other stuff besides queries in between trans_start() and trans_complete()? specifically I want to prep my data for the insertion into the table.
Code:
$this->db->transact_start();
$this->db->where('connection_request',$req_id);
$this->db->update('connection_request',array('status' => 'A'));
$this->db->where('connection_request',$req_id);
$this->db->select('object','subject','type');
$query = $this->db->get('connection_request');
foreach($query->result_array() as $row)
{
$connection = $row;
}
$connection['active'] = TRUE;
$connection['banner'] = FALSE;
$this->db->insert('connection',$connection);
$this->db->trans_complete();
Also if I am sure that the query will result in a single row, isn't there any method by which I can assign it directly to a variable rather then using foreach loop ?