SQL插入准备语句不起作用但更新确实如此

时间:2015-04-09 08:41:57

标签: php web prepared-statement

我有以下php代码

   $riziv = $_GET["riziv"];
   $answer1 = (int)$_GET["answer1"];
   $answer2 = (int)$_GET["answer2"];
   $name = $_get["name"];
   $first_name = $_get["first_name"];
   $city = $_get["city"];

   if (empty($riziv)) {
       $stmt = $this->db->prepare("INSERT INTO Doctors 
                 (name,first_name,city,answer1,answer2) 
                 VALUES (?,?,?,?,?)");
       $stmt->bind_param("sssdd",$name,$first_name,$city,$answer1,$answer2);
   }else{
       $stmt = $this->db->prepare("UPDATE Doctors SET answer1 = ?, answer2 = ? WHERE riziv=?");
       $stmt->bind_param("dds",$answer1,$answer2,$riziv);
   }

   $stmt->execute();
   $stmt->close();

   $this->db->commit();

更新正在运行但是bind_param行上的插入是否中断? 有人可以帮忙吗?

谢谢!

0 个答案:

没有答案