1
我試圖綁定$userId
值$_SESSION
存儲在insert select
聲明中,但它似乎是如此錯誤。Sql插入選擇語句PDO
class Cart {
public function addToCart($userId, $prodId) {
$sql = "INSERT INTO `cart` (prod_id, user_id, prod_title, prod_img,quantity, price)
SELECT product_id, //:user_id//, product_title, product_img, 1, product_price
FROM `products`
WHERE product_id = :product_id
";
$q = $this->_pdo->prepare($sql);
$q->execute([ 'user_id' => $userId , 'product_id' => $prodId]);
}
}
我只是嘗試在需要進行綁定 –
值集中在我的描述你檢查在'execute'的變化,我的回答 – Dekel
反正日Thnx的幫助 –