Sistem Informasi Sekolah Terintegrasi

Ambil ID Insert terakhir CI

Codeigniter   2021-10-28  

$this->db->insert_id();

Contoh :

function add_bill(){
        $params=array(
            'no_purchase' =>$post['no_po'],
            'supplier_id' =>$post['supplier_id'],
            'subtotal' =>$post['subtotal'],
            'discount' =>$post['discount'],
            'grandtotal' =>$post['grandtotal'],
            'note' =>$post['note'],
            'tanggal' =>$post['tanggal'],
            'order_deadline' =>$post['order_deadline'],
            'receipt_date' =>$post['receipt_date'],
            'user_id' =>$this->fungsi->user_login()->user_id

        );
        $this->db->insert('t_purchase',$params);
        return $this->db->insert_id();
    }