<?php

class Anggota_model extends CI_Model{

	function get($q=null,$kelas=null){

	if($q){
		$this->db->like('nama',$q);
		$this->db->or_like('nis',$q);
	}

	if($kelas){
		$this->db->where('kelas',$kelas);
	}

	return $this->db->get('anggota')->result();
}

function kelas(){
	$this->db->select('kelas');
	$this->db->group_by('kelas');
	return $this->db->get('anggota')->result();
}



	function insert($data){
		$this->db->insert('anggota',$data);
	}

	function edit($id){
		return $this->db->where('id_anggota',$id)->get('anggota')->row();
	}

	function update($id,$data){
		$this->db->where('id_anggota',$id);
		$this->db->update('anggota',$data);
	}

	function delete($id){
		$this->db->where('id_anggota',$id);
		$this->db->delete('anggota');
	}
	function by_nis($nis){
	return $this->db->where('nis',$nis)->get('anggota')->row();
}

}
