[eluser]rochellecanale14[/eluser]
Hello guys I just want to ask how can I get the last inserted ID using the
$this->db->insert_id() function. What I did is after my
$this->db->insert_id() and assigned it in a variable, when I echo the value of it. It display the first index ID of my array. I can't get the last inserted.
Here's my code:
Code:
for($x = 0; $x < sizeof($filtername); $x++){
$orders[] = array(
'poid' => null,
'order_id' => $poid,
'item_desc' => $filtername[$x],
'item_qty' => $filterquantity[$x],
'item_price' => $filterprice[$x],
'total' => $filtertotal[$x],
'cash_on_delivery' => $val_delivery,
'is_check' => $val_check,
'bank_transfer' => $val_transfer,
'transaction_date' => $dateorder
);
}
$this->db->insert_batch('po_order', $orders);
$v_poid = $this->db->insert_id(); //this will return the first inserted ID of my array
echo $v_poid;
exit;