1
$userId
の値を$_SESSION
のinsert select
ステートメントの中に格納してバインドしようとしていますが、間違っているようです。Sql Selectステートメントに挿入する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を助け –