【发布时间】:2020-05-13 22:20:57
【问题描述】:
我目前正在使用 PHP 和 MySQL 开发餐厅 POS 系统,并且有一个包含以下值的表 (open_tables): code、idSeller、tableNo、products、netPrice
现在我想打开表格,进行更改并将其保存到带有额外参数的不同表格(销售)中: code, idSeller, tableNo, idCustomer, products, netPrice, discount, totalPrice, paymentMethod。
我该怎么办?
这是我目前拥有的,但它给了我错误:
public static function ReopenSaleModel($table1, $table2, $data){
$stmt = Connection::connect()->prepare("INSERT INTO $table2 SELECT * FROM $table1 WHERE code, idSeller, tableNo, idCustomer, products, netPrice, discount, totalPrice, paymentMethod VALUES :code, :idSeller, :tableNo, :idCustomer, :products, :netPrice, :discount, :totalPrice, :paymentMethod");
$stmt->bindParam(":code", $data["code"], PDO::PARAM_INT);
$stmt->bindParam(":idSeller", $data["idSeller"], PDO::PARAM_INT);
$stmt->bindParam(":tableNo", $data["tableNo"], PDO::PARAM_STR);
$stmt->bindParam(":idCustomer", $data["idCustomer"], PDO::PARAM_STR);
$stmt->bindParam(":products", $data["products"], PDO::PARAM_STR);
$stmt->bindParam(":netPrice", $data["netPrice"], PDO::PARAM_STR);
$stmt->bindParam(":discount", $data["discount"], PDO::PARAM_STR);
$stmt->bindParam(":totalPrice", $data["totalPrice"], PDO::PARAM_STR);
$stmt->bindParam(":paymentMethod", $data["paymentMethod"], PDO::PARAM_STR);
if($stmt->execute()){
return "ok";
}else{
return "error";
}
$stmt->close();
$stmt = null;
}
【问题讨论】:
标签: php mysql sql select sql-insert