这是我的功能:
function create($printing_id,$Machine,$Started,$Grams,$color) {
//*
$this->sql = "insert into `".$this->tableName."` (`3dprinting_id`,`Machine`,`Started`,`Grams`,`color`) values ( :3dprinting_id , :Machine, :Started , :Grams , :color )";
$this->stmt = $this->dbh->prepare($this->sql);
$this->stmt->bindParam(":3dPrinting_id",$printing_id,PDO::PARAM_INT);
$this->stmt->bindParam(":Machine",$Machine,PDO::PARAM_STR);
$this->stmt->bindParam(":Started",$Started,PDO::PARAM_STR);
$this->stmt->bindParam(":Grams",$Grams,PDO::PARAM_INT);
$this->stmt->bindParam(":color",$color,PDO::PARAM_STR);
$this->params = array();
$this->params[":3dPrinting_id"] = $printing_id;
$this->params[":Machine"] = $Machine;
$this->params[":Started"] = $Started;
$this->params[":Grams"] = $Grams;
$this->params[":color"] = $color;
return $this->stmt->execute();
//*/
/*
$this->sql = "insert into `".$this->tableName."` (`3dprinting_id`,`Machine`,`Started`,`Grams`,`color`) values ($printing_id,'$Machine','$Started',$Grams,'$color')";
return $this->dbh->exec($this->sql);
//*/
}
当我以最佳方式(未注释掉)时,我收到HY093错误。当我这样做时,它的底部方式完美无缺。
在我的数据库中:
答案 0 :(得分:8)
就像变量一样,绑定区分大小写。
您的价值观( :3dprinting_id
然后你正在做
bindParam(":3dPrinting_id"
他们需要在字母大小写中匹配。
bindParam(":3dprinting_id"