我明白了
警告:PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: 参数号无效:参数未定义
当尝试运行以下代码时,两者bindValue
似乎bindParam
都看不到有什么问题。
class Product {
public function productAdd($x) {
$core = Core::getInstance(); // This part works OK
$stmt = $core->dbh->prepare('INSERT INTO Product (Product_Name) VALUES (:product-name)');
$stmt->bindValue(':product-name', $x, PDO::PARAM_STR);
$stmt->execute();
}
}
$product = new Product;
$productadd = $product->productAdd('Blue Sunglasses');