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

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

}