Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public function insert_user($name, $desc)
  2. {
  3. $this->db->trans_start(TRUE);
  4. $this->db->set('Name', $name);
  5. $this->db->set('Desc', $desc);
  6. $this->db->insert('user');
  7. $id = $this->db->insert_id();
  8. $this->db->trans_complete();
  9. return $id;
  10.  
  11. if ($this->db->trans_status() === TRUE)
  12. {
  13. insert_access($get);
  14. }
  15.  
  16. public function insert_access($get)
  17. {
  18. $data = $this->input->post('pTableData');
  19. $tableData = json_decode($data,TRUE);
  20. foreach ($tableData as $get)
  21. {
  22. $this->db->set('UserID', $id);
  23. $this->db->set('AccessName', $get['accessName']);
  24. $this->db->set('Password', $get['password']);
  25. $this->db->insert('access');
  26. $id_access = $this->db->insert_id();
  27.  
  28. return $id_access ;
  29. }
  30. }
  31.  
  32. $id = $this->db->insert_id();
  33. if ($this->db->trans_status() === TRUE)
  34. {
  35. $this->insert_access($id); //if in the same model
  36. $this->another_model->insert_access($id); //if some other model
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement