我用事先準備好的聲明中插入一個訂單到訂單表,但現在我想的訂單項目插入基礎上插入訂單表中的最後一個ID的訂單項目表:什麼是mysql_insert_id();使用準備好的語句
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();
使用預處理語句?
什麼是你的問題? – 2012-03-17 21:08:30
什麼是mysql_insert_id();在準備好的陳述風格? – user1227124 2012-03-17 21:09:54
你的意思是,PDO庫中的'mysql_insert_id'等價於什麼? [文檔]有問題(http://www.php.net/manual/en/pdo.lastinsertid.php)? – 2012-03-17 21:17:49