I have a query, i have written a program in such a way an entry created in database and i am getting last_id, used this last id to update in second table.
$table='user';
$data = array('array having user data');
$this->db->insert($table, $data);
$last_id = $this->db->insert_id();
$this->db->where('user_id', $last_id);
$this->db->set('wallet_total_amount', "wallet_total_amount");
In such program when two entries created at exactly same time then the id of second transaction updated with first record. how to avoid this. please suggest.