I found an exercise in mysql and I'm passing it to postgresql, but I get to a part where this "mysql_insert_id" I understand that is to get the last record and also found "mysqli_multi_query" I have no idea how to change it to Postgresql.
<?php
if(isset($_POST["place_order"]))
{
$insert_order = "
INSERT INTO tbl_order(customer_id, creation_date, order_status)
VALUES('1', '".date('Y-m-d')."', 'pending')
";
$order_id = "";
if(pg_query($connect, $insert_order))
{
$order_id = mysql_insert_id($connect);
}
$_SESSION["order_id"] = $order_id;
$order_details = "";
foreach($_SESSION["shopping_cart"] as $keys => $values)
{
$order_details .= "
INSERT INTO tbl_order_details(order_id, product_name, product_price, product_quantity)
VALUES('".$order_id."', '".$values["product_name"]."', '".$values["product_price"]."', '".$values["product_quantity"]."');
";
}
if(mysqli_multi_query($connect, $order_details))
{
unset($_SESSION["shopping_cart"]);
echo '<script>alert("You have successfully place an order...Thank you")</script>';
echo '<script>window.location.href="cart.php"</script>';
}
}