Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php class M_pasien extends CI_Model{
- function __construct(){
- parent::__construct();
- }
- function tampil_pasien($num, $offset){
- $this->db->select(array( 'id', 'namalengkap', 'umur', 'alamat', "DATE_FORMAT(lastinput,'%d-%m-%Y') as tanggal" ), FALSE);
- $this->db->where('tampil', 1);
- $this->db->order_by('id', 'DESC');
- $this->db->limit($num, $offset);
- $query = $this->db->get('pasien');
- //$query = $this->db->get('pasien',$num, $offset);
- return $query->result();
- }
- function simpan_pasien($data){
- $this->db->insert('pasien', $data);
- }
- function ambil_pasien($id){
- $query = $this->db->get_where('pasien', array('id'=>$id));
- return $query->row();
- }
- function update_pasien($data, $id){
- $this->db->where('id', $id);
- $this->db->update('pasien', $data);
- }
- function cari_pasien($num, $offset, $nama, $alamat){
- $this->db->select(array('id', 'namalengkap', 'umur', 'alamat', "DATE_FORMAT(lastinput,'%d-%m-%Y') as tanggal"), FALSE);
- if($nama <> ""){
- $this->db->or_like('namalengkap', $nama);
- }
- if($alamat <> ""){
- $this->db->or_where('alamat', $alamat);
- }
- $this->db->order_by('namalengkap', 'ASC');
- $query = $this->db->get('pasien', $num, $offset);
- return $query;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment