I Want To insert data in transaction table and at the same time update customer table in codeigniter (codeigniter) I Want To insert data in transaction table and at the same time update customer table . 
I want to Add value of ChangeDue in transation table To value now_debt in Customer Table

Function in transaction Model

public function add($_iN, $_iC, $desc, $q, $qs, $_up, $_tp, $change_due, 
$cn) {
$data = ['itemName' =&gt; $_iN, 'itemCode' =&gt; $_iC, 'description' =&gt; $desc,
'quantity' =&gt; $q, 'quantitys' =&gt; $qs, 'unitPrice' =&gt; $_up, 
'totalPrice' =&gt; $_tp,'changeDue' =&gt; $change_due,'cust_id'=&gt;$cn];
     $this-&gt;db-&gt;insert('transactions', $data);
     $this-&gt;db-&gt;set('customer.now_debt', 'customer.now_debt' + $change_due);
     $this-&gt;db-&gt;where('customer_id', $cn);
     $this-&gt;db-&gt;join('transactions', 'transactions.cust_id = 
     customer.customer_id');
    $this-&gt;db-&gt;update('customer');
    if ($this-&gt;db-&gt;affected_rows()) {
        return $this-&gt;db-&gt;insert_id();
    }
    else {
        return FALSE;
    }
}
Codeigniter does not support join for update in active records. You need to update your code as follows:

public function add($_iN, $_iC, $desc, $q, $qs, $_up, $_tp, $change_due, 
$cn) {
$data = ['itemName' =&gt; $_iN, 'itemCode' =&gt; $_iC, 'description' =&gt; $desc,
'quantity' =&gt; $q, 'quantitys' =&gt; $qs, 'unitPrice' =&gt; $_up, 
'totalPrice' =&gt; $_tp,'changeDue' =&gt; $change_due,'cust_id'=&gt;$cn];
     $this-&gt;db-&gt;insert('transactions', $data);
     $updateSuccess=$this-&gt;db-&gt;query('customer JOIN transactions ON transactions.cust_id = customer.customer_id SET customer.now_debt = customer.now_debt + ? where customer_id = ? ' , array($change_due,$cn));
    if ($updateSuccess) {
        return $this-&gt;db-&gt;insert_id();
    }
    else {
        log_message('error',$this-&gt;db-&gt;error());
        return FALSE;
    }
}