<?php
class Download_m extends CI_Model {
    

    function __construct()
    {        
        parent::__construct();
    }
	
	public function tampil($id)
    {
		$this->d_pas = $this->load->database('default', TRUE);
		$query = $this->d_pas->query("SELECT * FROM at_download where tenan_id='$id'");
        $b=$query->result();
		return $b;
    }
	
	public function hal($id)
    {
		$this->d_pas = $this->load->database('default', TRUE);
		$query = $this->d_pas->query("SELECT * FROM at_download where tenan_id='$id'");
        $b=$query->num_rows();
		return $b;
    }
	
	public function download_semua($cari, $tenan_id, $limit)
    {
		$this->d_pas = $this->load->database('default', TRUE);
        $query = $this->d_pas->query("SELECT * FROM at_download where tenan_id='$tenan_id' order by id DESC $limit");
        return $query->result();
		
    }
	
	public function simpan($judul, $isi,  $tenan_id)
    {
		$data = array(
        'judul' => $judul, 
        'isi' => $isi,
        'tenan_id' => $tenan_id
        );
		$str = $this->db->insert_string('at_download', $data);
        mysql_query($str);
    }
	
	public function editsimpan($a, $judul, $isi,  $tenan_id)
    {
		$data = array(
        'judul' => $judul, 
        'isi' => $isi
        );

		$this->db->where('id', $a);
		$this->db->where('tenan_id', $tenan_id);
		$this->db->update('at_download', $data); 
    }
    
    	
	public function hapus($a, $b)
    {
		$this->db->where('id', $a);
		$this->db->where('tenan_id', $b);
		$this->db->delete('at_download'); 
    }

}