вот моя функция:
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. Когда я делаю это снизу, это работает отлично.
В моей базе данных:
Как и переменные, привязки чувствительны к регистру.
У вас есть это в ваших ценностях ( :3dprinting_id
а потом ты делаешь
bindParam(":3dPrinting_id"
Они должны совпадать в регистре букв.
bindParam(":3dprinting_id"
Других решений пока нет …