我试图通过此功能创建一个新对象。但是,这不会起作用。问题是我没有收到任何错误,也没有输出消息。
以下是我使用的代码:
public function create($obj){
try{
$requete=$this->bdd->bd->prepare('INSERT INTO fiche (mois, annee, nbFiches, statut, commentaire, intervenant0, charge0, tauxCharge0, intervenant1, charge1, tauxCharge1, intervenant2, charge2, tauxCharge2, intervenant3, charge3, tauxCharge3, intervenant4, charge4, tauxCharge4, intervenant5, charge5, tauxCharge5, intervenant6, charge6, tauxCharge6, intervenant7, charge7, tauxCharge7, intervenant8, charge8, tauxCharge8, intervenant9, charge9, tauxCharge9) VALUES (:mois, :annee, :nbFiches, :statut, :commentaire, :intervenant0, :charge0, :tauxCharge0, :intervenant1, :charge1, :tauxCharge1, :intervenant2, :charge2, :tauxCharge2, :intervenant3, :charge3, :tauxCharge3, :intervenant4, :charge4, :tauxCharge4, :intervenant5, :charge5, :tauxCharge5, :intervenant6, :charge6, :tauxCharge6, :intervenant7, :charge7, :tauxCharge7, :intervenant8, :charge8, :tauxCharge8, :intervenant9, :charge9, :tauxCharge9)');
$requete->bindValue(':mois', $obj->getMois(), PDO::PARAM_INT);
$requete->bindValue(':annee', $obj->getAnnee(), PDO::PARAM_INT);
$requete->bindValue(':nbFiches', $obj->getNbFiches(), PDO::PARAM_INT);
$requete->bindValue(':statut', $obj->getStatut(), PDO::PARAM_STR);
$requete->bindValue(':commentaire', $obj->getCommentaire(), PDO::PARAM_STR);
$requete->bindValue(':intervenant0', $obj->getIntervenant0(), PDO::PARAM_STR);
$requete->bindValue(':charge0', $obj->getCharge0(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge0', $obj->getTauxCharge0(), PDO::PARAM_INT);
$requete->bindValue(':intervenant1', $obj->getIntervenant1(), PDO::PARAM_STR);
$requete->bindValue(':charge1', $obj->getCharge1(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge1', $obj->getTauxCharge1(), PDO::PARAM_INT);
$requete->bindValue(':intervenant2', $obj->getIntervenant2(), PDO::PARAM_STR);
$requete->bindValue(':charge2', $obj->getCharge2(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge2', $obj->getTauxCharge2(), PDO::PARAM_INT);
$requete->bindValue(':intervenant3', $obj->getIntervenant3(), PDO::PARAM_STR);
$requete->bindValue(':charge3', $obj->getCharge3(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge3', $obj->getTauxCharge3(), PDO::PARAM_INT);
$requete->bindValue(':intervenant4', $obj->getIntervenant4(), PDO::PARAM_STR);
$requete->bindValue(':charge4', $obj->getCharge4(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge4', $obj->getTauxCharge4(), PDO::PARAM_INT);
$requete->bindValue(':intervenant5', $obj->getIntervenant5(), PDO::PARAM_STR);
$requete->bindValue(':charge5', $obj->getCharge5(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge5', $obj->getTauxCharge5(), PDO::PARAM_INT);
$requete->bindValue(':intervenant6', $obj->getIntervenant6(), PDO::PARAM_STR);
$requete->bindValue(':charge6', $obj->getCharge6(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge6', $obj->getTauxCharge6(), PDO::PARAM_INT);
$requete->bindValue(':intervenant7', $obj->getIntervenant7(), PDO::PARAM_STR);
$requete->bindValue(':charge7', $obj->getCharge7(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge7', $obj->getTauxCharge7(), PDO::PARAM_INT);
$requete->bindValue(':intervenant8', $obj->getIntervenant8(), PDO::PARAM_STR);
$requete->bindValue(':charge8', $obj->getCharge8(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge8', $obj->getTauxCharge8(), PDO::PARAM_INT);
$requete->bindValue(':intervenant9', $obj->getIntervenant9(), PDO::PARAM_STR);
$requete->bindValue(':charge9', $obj->getCharge9(), PDO::PARAM_INT);
$requete->bindValue(':tauxCharge9', $obj->getTauxCharge9(), PDO::PARAM_INT);
$requete->execute();
//$nouveauobj = $this->bdd->bd->lastInsertId();
$requete->CloseCursor();
} catch (Exception $e){
die('Erreur: ' . $e->getMessage());
}
}
请问如何解决这个问题?怎么了?请注意,我使用相同的代码来选择和删除行,并且它能够正常运行。