67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Produk_model extends CI_Model
|
|
{
|
|
public function get_unique_kategori() {
|
|
$this->db->distinct();
|
|
$this->db->select('kategori');
|
|
$query = $this->db->get('produk');
|
|
return $query->result_array();
|
|
}
|
|
|
|
public function countall()
|
|
{
|
|
return $this->db->count_all('produk');
|
|
}
|
|
|
|
public function get_all_produk($sort = 'asc')
|
|
{
|
|
$this->db->order_by('id_produk', $sort);
|
|
return $this->db->get('produk');
|
|
}
|
|
|
|
public function get_all_produk_api()
|
|
{
|
|
return $this->db->get('produk');
|
|
}
|
|
|
|
public function get_produk($id_produk)
|
|
{
|
|
$this->db->where('id_produk', $id_produk);
|
|
return $this->db->get('produk');
|
|
}
|
|
|
|
public function search_produk($kata_kunci = '')
|
|
{
|
|
if (!empty($kata_kunci)) {
|
|
$this->db->like('nama_produk', $kata_kunci);
|
|
}
|
|
return $this->db->get('produk');
|
|
}
|
|
|
|
public function add_produk($params)
|
|
{
|
|
return $this->db->insert('produk', $params);
|
|
}
|
|
|
|
public function update_produk($id_produk, $params)
|
|
{
|
|
$this->db->where('id_produk', $id_produk);
|
|
return $this->db->update('produk', $params);
|
|
}
|
|
|
|
public function get_kategori($kategori)
|
|
{
|
|
$this->db->where('kategori', $kategori);
|
|
return $this->db->get('produk');
|
|
}
|
|
|
|
public function delete_produk($id_produk)
|
|
{
|
|
$this->db->where('id_produk', $id_produk);
|
|
return $this->db->delete('produk');
|
|
}
|
|
}
|
|
|
|
?>
|