tambah fitur produk
This commit is contained in:
47
application/models/ProdukModel.php
Normal file
47
application/models/ProdukModel.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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 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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user