我尝试复制我的数据库的一行但我的功能不起作用并且没有返回错误php或打印错误我的var dump仅返回数组(size = 1) ' ID' =>字符串' 11',
我的控制器中的代码:
public function duplicateOutil(){
var_dump($_POST);
if (isset($_POST["id"])){
$o = new Outillage($_POST["id"]);
if (isset($_POST["id_art"])){
$o->__set("id_art", $_POST["id_art"]);
}
if (isset($_POST["num_serie"])){
$o->__set("num_serie",$_POST["num_serie"]);
}
if (isset($_POST["article"])){
$o->__set("article", $_POST["art"]);
}
if (isset($_POST["id_doc"])){
$o->__set("id_doc", $_POST["id_doc"]);
}
if (isset($_POST["document"])){
$o->__set("document", $_POST["doc"]);
}
if (isset($_POST["ilot"])){
$o->__set("ilot", ilot::findAllByName($_POST["ilot"]));
}
if (isset($_POST["emplacement"])){
$o->__set("emplacement", $_POST["emplacement"]);
}
if (isset($_POST["liste_tubes"])){
$o->__set("liste_tubes", $_POST["tube"]);
}
$o->insert();
}else{
echo('erreur');
}
}
sql函数:
public function duplicate() {
try{
$c = base::getConnection();
$query=$c->prepare ("INSERT INTO outillage(num_serie,id_art,article,id_doc,document,ilot,emplacement,liste_tubes) SELECT (:num_serie,:id_art,:article,:id_doc,:document,:ilot,:emplacement,:liste_tubes WHERE id=:id);");
$query->bindParam(':id',$this->id,PDO::PARAM_INT);
$query->bindParam(':id_art',$this->id_art,PDO::PARAM_INT);
$query->bindParam(':num_serie',$this->num_serie,PDO::PARAM_STR);
$query->bindParam(':article',$this->article,PDO::PARAM_STR);
$query->bindParam(':id_doc',$this->id_doc,PDO::PARAM_STR);
$query->bindParam(':document',$this->document,PDO::PARAM_STR);
$query->bindParam(':ilot',$this->ilot,PDO::PARAM_INT);
$query->bindParam(':emplacement',$this->emplacement,PDO::PARAM_STR);
$query->bindParam(':liste_tubes',$this->liste_tubes,PDO::PARAM_STR);
$query->execute();
}
catch (Exception $e){
echo $e->getMessage();
}
}
和我要复制的html按钮:
<form method="post" action="Site.php?a=duplicateOutil" onsubmit="">
<button type="button" class="btn btn-default" data-dismiss="modal">Non</button>
<input name="id" type="hidden" type="text" value="'.$l->__get("id").'">
<input id="confirmer" type="submit" value="Oui" class=btn btn-primary">
</form>