Почему я получаю ошибку HY093 [PDO]

вот моя функция:

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 — это int, не может быть нулевым
  • Машина varchar (30), может быть нулевой
  • Начато время-дата, не может быть нулевым
  • Грамм является целым числом, может быть нулевым
  • цвет varchar (30), может быть нулевым

5

Решение

Как и переменные, привязки чувствительны к регистру.

У вас есть это в ваших ценностях ( :3dprinting_id

а потом ты делаешь

bindParam(":3dPrinting_id"

Они должны совпадать в регистре букв.

bindParam(":3dprinting_id"
8

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector