62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<?php
|
|
|
|
class ProdukModel extends CI_Model
|
|
{
|
|
private $_table = "tb_produk";
|
|
|
|
public function save($id_umkm)
|
|
{
|
|
$post = $this->input->post();
|
|
$this->id_umkm = $id_umkm;
|
|
$this->produk = $post["produk"];
|
|
$this->deskripsi = $post["deskripsi"];
|
|
|
|
$this->foto_produk = "default.png";
|
|
return $this->db->insert($this->_table, $this);
|
|
}
|
|
|
|
public function getProdukByUmkmId($id_umkm){
|
|
$this->db->where('id_umkm', $id_umkm);
|
|
$this->db->order_by('produk', 'DESC');
|
|
return $produk = $this->db->get($this->_table)->result();
|
|
}
|
|
|
|
public function getProdukById($id_produk){
|
|
$this->db->where('id_produk', $id_produk);
|
|
return $produk = $this->db->get($this->_table)->row();
|
|
}
|
|
|
|
public function getProduk(){
|
|
$this->db->join('tb_umkm','tb_umkm.id_umkm = tb_produk.id_umkm');
|
|
return $produk = $this->db->get($this->_table)->result();
|
|
}
|
|
|
|
public function getProdukCount(){
|
|
return $produk = count($this->db->get($this->_table)->result());
|
|
}
|
|
|
|
public function getThree(){
|
|
$this->db->order_by('id_produk', 'DESC');
|
|
$this->db->limit('6');
|
|
return $produk = $this->db->get($this->_table)->result();
|
|
}
|
|
|
|
public function getLastProdukByIdUmkm($id_umkm){
|
|
$this->db->where('id_umkm', $id_umkm);
|
|
$this->db->order_by('id_produk', 'DESC');
|
|
return $umkm = $this->db->get($this->_table)->row();
|
|
}
|
|
|
|
public function setFirstImage($id_produk,$foto_produk)
|
|
{
|
|
$this->foto_produk = $foto_produk;
|
|
return $this->db->update($this->_table, $this, array('id_produk' => $id_produk));
|
|
}
|
|
|
|
public function delete($id_produk)
|
|
{
|
|
return $this->db->delete($this->_table, array("id_produk" => $id_produk));
|
|
}
|
|
|
|
|
|
} |