Я использовал подготовленный оператор для вставки заказа в таблицу заказов, но теперь я хочу вставить позиции заказа в таблицу позиций заказов на основе последнего идентификатора, вставленного в таблицу заказов:
if (isset($_POST['process'])) {
$order_name = $_POST['order_name'];
//create initial order
$stmt = $conn2->prepare("INSERT INTO orders (order_name) VALUES (?)");
$stmt->bind_param('s', $order_name);
$stmt->execute();
//this gets the most recent auto incremented ID from the database - this is the order_id we have just created
$order_id = mysql_insert_id();
//loop over all of our order items and add to the database
foreach ($_SESSION['order'] as $item) {
Что эквивалентно mysql_insert_id();
с использованием подготовленного заявления?