Codeigniter库多个实例,无法正常工作

Iam developing a codeigniter POS system project.

I have separate sections to product sale and product GRN. both are using codeigniter cart library

in product sale section I created instance called : ocart

$this->load->library('cart','','ocart');
$ocart = $this->ocart->contents();
$this->ocart->destroy();
$this->ocart->insert($data);

product GRN section I created separate instance called : pcart

$this->load->library('cart','','pcart');
$pcart = $this->pcart->contents();
$this->pcart->destroy();
$this->pcart->insert($data);

When Im going to add product to the cart in sale section, same time same product added to the product GRN cart also. and wise versa.

then I checked array contents using print_r($pcart) and print_r($ocart);

both giving same output

Array
(
    [6b913a2317d00f7bfa0abdaff1a1f67f] => Array
        (
            [rowid] => 6b913a2317d00f7bfa0abdaff1a1f67f
            [id] => 22020
            [pcode] => DS141
            [note] => PLATE
            [qty] => 20
            [price] => 1
            [name] => 97280
            [subtotal] => 20
        )

)

what is wrong with above code, please advice.

There is no built-in method to destroy loaded library object. You can do simply like that by using unset or setting null.

unset($this->my_library);

OR

$this->my_library = null;