<?php
class Halaman_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_hal 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_hal where tenan_id='$id'");
        $b=$query->num_rows();
		return $b;
    }
	
	public function halaman_semua($cari, $tenan_id, $limit)
    {
		$this->d_pas = $this->load->database('default', TRUE);
        $query = $this->d_pas->query("SELECT * FROM at_hal where tenan_id='$tenan_id' order by id DESC $limit");
        return $query->result();
		
    }
	
	public function simpan($judul_ind, $judul_ing, $isi_ind, $isi_ing)
    {
		$data = array(
        'judul_ind' => $judul_ind, 
        'judul_ing' => $judul_ing,
        'isi_ind' => $isi_ind, 
        'isi_ing' => $isi_ing
        );
		$str = $this->db->insert_string('at_hal', $data);
        mysql_query($str);
    }
	
	public function editsimpan($a, $judul_ind, $judul_ing, $isi_ind, $isi_ing)
    {
		$data = array(
        'judul_ind' => $judul_ind, 
        'judul_ing' => $judul_ing,
        'isi_ind' =>  $isi_ind, 
        'isi_ing' => $isi_ing
        );

		$this->db->where('id', $a);
		$this->db->update('at_hal', $data); 
    }
    
}