<?php
class Gallery_m extends CI_Model {
    

    function __construct()
    {        
        parent::__construct();
    }
	
	
    
    public function semua($tipe, $limit)
    {
		$this->d_pas = $this->load->database('default', TRUE);
        $query = $this->d_pas->query("SELECT * FROM at_galeri where galeri_id='$tipe' order by id DESC $limit");
        return $query->result();
    }
    
        
    public function jum_hal($tipe)
    {
		$this->d_pas = $this->load->database('default', TRUE);
        $query = $this->d_pas->query("SELECT * FROM at_galeri where galeri_id='$tipe'");
        return $query->num_rows();
    }
    
    public function simpan($judul_ind, $judul_ing, $foto, $tipe)
    {
		$data = array(
        'judul_ind' => $judul_ind, 
        'judul_ing' => $judul_ing,
        'gambar' => $foto,
        'galeri_id' => $tipe
        );
		$str = $this->db->insert_string('at_galeri', $data);
        mysql_query($str);
    }
	
	public function editsimpan($a, $judul_ind, $judul_ing, $foto, $tipe)
    {
		$data = array(
        'judul_ind' => $judul_ind, 
        'judul_ing' => $judul_ing,
        'gambar' => $foto,
        'galeri_id' => $tipe
        );

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


}