我正在尝试将订单详细信息插入mysql DB,但它无法正常工作。以下是课程和功能
class Order extends Database {
public function insertOrderRef($sessid, $sessionmember, $total) {
$sql = "INSERT INTO `orders` (order-id, total, member-id, complete) VALUES (:sessid,:total,:sessionmember, '0')";
$q = $this->conn->prepare($sql);
$q->execute(array(':sessid'=>$sessid,':total'=>$total,':sessionmember'=>$sessionmember));
}
}
这是函数调用
$createorder = new Order;
$createorder->insertOrderRef($sessid, $sessionmember, $total);
我哪里错了?
答案 0 :(得分:4)
如果列名使用连字符,则需要将它们关闭为反引号。
$sql = "INSERT INTO `orders` (`order-id`, `total`, `member-id`, `complete`) VALUES (:sessid,:total,:sessionmember, '0')";