我正在尝试mysqli_multi_query
。出于某种原因,它不会起作用。
以下是我到目前为止所做的事情:
<?php
$con=mysqli_connect("host","user","pw","db");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$orderid = $_GET['orderid'];
$sql = "INSERT INTO orders_archive SELECT * FROM orders WHERE orders_id='".$orderid."'";
$sql .= "DELETE FROM orders WHERE orders_id='".$orderid."'";
mysqli_multi_query($con,$sql);
mysqli_close($con);
?>
orderid
由ajax授予。
答案 0 :(得分:1)
查询必须用;
分隔。
$sql = "INSERT INTO orders_archive SELECT * FROM orders WHERE orders_id='".$orderid."';";
$sql .= "DELETE FROM orders WHERE orders_id='".$orderid."'";
答案 1 :(得分:1)
您需要在查询末尾添加semicolun才能将其分隔
$sql = "INSERT INTO orders_archive SELECT * FROM orders WHERE orders_id='".$orderid."';";
$sql .= "DELETE FROM orders WHERE orders_id='".$orderid."'";