0

我收到此错误:

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /FondManager.class.php on line 69

尝试执行此操作时:

$Fond_Modif = $Manager->get($id);
$Fond_Modif->setContactname($_POST['name']);
$Manager->update($Fond_Modif);

这是有关的课程:

 public function update(Fond $Fond)
  {
    $q = $this->_db->prepare('UPDATE fonds SET Name, ContactName, ContactPosition, ContactMail, ContactPhone, Website, MinTic, MaxTic WHERE id = :id');

    $q->bindValue(':id', $Fond->id());
    $q->bindValue(':name', $Fond->name(), PDO::PARAM_INT);
    $q->bindValue(':contactname', $Fond->contactname(), PDO::PARAM_INT);
    $q->bindValue(':contactposition', $Fond->contactposition(), PDO::PARAM_INT);
    $q->bindValue(':contactmail', $Fond->contactmail(), PDO::PARAM_INT);
    $q->bindValue(':contactphone', $Fond->contactphone(), PDO::PARAM_INT);
    $q->bindValue(':website', $Fond->website(), PDO::PARAM_INT);
    $q->bindValue(':mintic', $Fond->mintic(), PDO::PARAM_INT);
    $q->bindValue(':maxtic', $Fond->maxtic(), PDO::PARAM_INT);

    $q->execute();
  }
4

1 回答 1

7

您必须在查询中“提及”所有占位符

$q = $this->_db->prepare("UPDATE fonds 
                          SET Name = :name,
                          ContactName = :contactname,  
                          ContactPosition = :contactposition, 
                          ContactMail = :contactmail,
                          ContactPhone = :contactphone, 
                          Website = :website
                          MinTic = :mintic, 
                          MaxTic = :maxtic
                          WHERE id = :id");

PDO 仅替换占位符。您必须将该占位符添加到您的查询中。

于 2012-11-29T18:19:31.427 回答