anjhar

m_pasien

Mar 14th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php class M_pasien extends CI_Model{
  2. function __construct(){
  3. parent::__construct();
  4. }
  5.  
  6. function tampil_pasien($num, $offset){
  7. $this->db->select(array( 'id', 'namalengkap', 'umur', 'alamat', "DATE_FORMAT(lastinput,'%d-%m-%Y') as tanggal" ), FALSE);
  8. $this->db->where('tampil', 1);
  9. $this->db->order_by('id', 'DESC');
  10. $this->db->limit($num, $offset);
  11. $query = $this->db->get('pasien');
  12. //$query = $this->db->get('pasien',$num, $offset);
  13. return $query->result();
  14. }
  15.  
  16. function simpan_pasien($data){
  17. $this->db->insert('pasien', $data);
  18. }
  19.  
  20. function ambil_pasien($id){
  21. $query = $this->db->get_where('pasien', array('id'=>$id));
  22. return $query->row();
  23. }
  24.  
  25. function update_pasien($data, $id){
  26. $this->db->where('id', $id);
  27. $this->db->update('pasien', $data);
  28. }
  29.  
  30. function cari_pasien($num, $offset, $nama, $alamat){
  31. $this->db->select(array('id', 'namalengkap', 'umur', 'alamat', "DATE_FORMAT(lastinput,'%d-%m-%Y') as tanggal"), FALSE);
  32. if($nama <> ""){
  33. $this->db->or_like('namalengkap', $nama);
  34. }
  35. if($alamat <> ""){
  36. $this->db->or_where('alamat', $alamat);
  37. }
  38. $this->db->order_by('namalengkap', 'ASC');
  39. $query = $this->db->get('pasien', $num, $offset);
  40. return $query;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment