Advertisement
Guest User

model-form

a guest
Feb 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. */
  5. class Model_input extends CI_Model
  6. {
  7.  
  8. function __construct()
  9. {
  10. parent::__construct();
  11. return $this->db->get('data_tamu');
  12. }
  13.  
  14. public function insert($data,$table)
  15. {
  16. /*$data = array(
  17. 'nama' => $this->input->post('nama'),
  18. 'instansi' => $this->input->post('instansi'),
  19. 'alamat' => $this->input->post('alamat'),
  20. 'peg_ditemui' => $this->input->post('peg_ditemui'),
  21. 'ket' => $this->input->post('ket')
  22. );
  23.  
  24. $this->db->insert('data_tamu', $data);
  25. $id = $this->db->insert_id();
  26. return (isset($id)) ? $id : FALSE;*/
  27.  
  28. $this->db->insert($table,$data);
  29.  
  30. $id=$this->db->insert_id();
  31. if($table=='data_tamu'){
  32. //==========UPDATE============
  33. $data=array(
  34. 'waktu' => 123,
  35. 'tanggal' => 456
  36. );
  37. $where="id_tamu='$id'";
  38. $str = $this->db->update_string($table, $data, $where);
  39. $str = str_replace("123","CURTIME()",$str);
  40. $str = str_replace("456","CURDATE()",$str);
  41. $this->db->query($str);
  42.  
  43. //die($str);
  44. $this->db->reset_query();
  45. $this->db->where("id_tamu",$id);
  46. $data=$this->db->get($table)->result();
  47. //die("id=".$id."<pre>".print_r($data,1));
  48. }
  49. return $id;
  50. }
  51.  
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement