daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Perawatan_model extends CI_Model {
  5.  
  6.     public function __construct()
  7.     {
  8.         $this->load->database();
  9.     }
  10.  
  11.     //Listing
  12.     public function listing ()
  13.     {
  14.         $this->db->select('perawatan.*, aset.nama_barang');
  15.         $this->db->from('perawatan');
  16.         //relasi ASET dan RUANGAN
  17.         $this->db->join('aset', 'aset.id_barang = perawatan.id_barang', 'LEFT');               
  18.         //end relasi
  19.         $this->db->order_by('id_rawat', 'DESC');
  20.         $query  = $this->db->get();
  21.         return $query->result();
  22.     }
  23.  
  24.     public function detail ($id_rawat)
  25.     {
  26.       $query  = $this->db->get_where('perawatan', array('id_rawat => id_rawat'));
  27.       return $query->row();
  28.     }
  29.  
  30.     public function tambah($data)
  31.     {
  32.       $this->db->insert('perawatan', $data);
  33.  
  34.     }
  35.  
  36.     public function update($data)
  37.     {
  38.       $this->db->where('id_barang', $data['id_barang']);
  39.       $this->db->update('aset', $data);
  40.     }
  41.  
  42.     /*Edit
  43.     public function edit($data)
  44.     {
  45.       $this->db->where('id_rawat', $data['id_rawat']);
  46.       $this->db->update('perawatan', $data);
  47.     }
  48.  
  49.     //Delete
  50.     public function delete($data)
  51.     {
  52.       $this->db->where('id_rawat', $data['id_rawat']);
  53.       $this->db->delete('perawatan', $data);
  54.     }*/
  55.  
  56.   }
RAW Paste Data
Top