<?php
defined('BASEPATH') or exit('No direct script access allowed');


class Keranjang_model extends CI_Model
{
    public function add_keranjang($params)
    {
        return $this->db->insert('keranjang', $params);
    }

    public function get_keranjang($id_pembeli)
    {
        $this->db->where('keranjang.id_pembeli', $id_pembeli);
        $this->db->join('pembeli', 'pembeli.id_pembeli=keranjang.id_pembeli', 'left');
        $this->db->join('produk', 'produk.id_produk=keranjang.id_produk', 'left');
        return $this->db->get('keranjang');
    }

    public function delete_keranjang_item($id_keranjang)
    {
        $this->db->where('id_keranjang', $id_keranjang);
        return $this->db->delete('keranjang');
    }

    public function delete_keranjang($id_pembeli)
    {
        $this->db->where('id_pembeli', $id_pembeli);
        return $this->db->delete('keranjang');
    }
}
?>