Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ModelKategori extends CI_Model {
- var $table = "kategori";
- var $primaryKey = "id_kategori";
- public function insert($data) {
- return $this->db->insert($this->table, $data);
- }
- public function insertGetId($data) {
- $this->db->insert($this->table, $data);
- return $this->db->insert_id();
- }
- public function getAll() {
- //hanya mengembalikan data yang is_active = 1
- $this->db->where("is_active", 1);
- return $this->db->get($this->table)->result();
- }
- public function getByPrimaryKey($id) {
- $this->db->where($this->primaryKey, $id);
- return $this->db->get($this->table)->row();
- }
- public function update($id, $data) {
- $this->db->where($this->primaryKey, $id);
- return $this->db->update($this->table, $data);
- }
- // delete data
- public function delete($id) {
- //hanya mengupdate is_active dari 1 menjadi 0
- $this->db->where($this->primaryKey, $id);
- return $this->db->update($this->table, array("is_active" => 0));
- }
- public function getJoin(){
- $this->db->select('barang.*,kategori.nama_kategori');
- $this->db->from('barang');
- $this->db->join('kategori','barang');
- $query = $this->db->get();
- return $query;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement