<?php
class Admin_m extends CI_Model {
    

    function __construct()
    {        
        parent::__construct();
    }
	
	
    
    public function semua($aa, $limit)
    {
		$this->d_pas = $this->load->database('default', TRUE);
        $query = $this->d_pas->query("SELECT * FROM at_login where hak='$aa' order by username DESC $limit");
        return $query->result();
    }
    
        
    public function jum_hal($aa)
    {
		$this->d_pas = $this->load->database('default', TRUE);
        $query = $this->d_pas->query("SELECT * FROM at_login where hak='$aa'");
        return $query->num_rows();
    }
    
    public function simpan($username, $nama, $hak, $sandi)
    {
		$data = array('username' => $username, 'nama' => $nama, 'hak' => $hak, 'sandi' => md5($sandi));
		$str = $this->db->insert_string('at_login', $data);
        mysql_query($str);
    }
	
	public function editsimpan($a, $username, $nama, $hak, $sandi)
    {
		$data = array('username' => $username, 'nama' => $nama, 'hak' => $hak, 'sandi' => md5($sandi));

		$this->db->where('username', $a);
		$this->db->update('at_login', $data); 
    }
    
    	
	public function hapus($a)
    {
		$this->db->where('username', $a);
		$this->db->delete('at_login'); 
    }


}