MySqli 预处理

   $mysqli = new mysqli("localhost","root","root","test");
   $sql = "insert into book (bookn,bookp,booka,addr)
           values(?,?,?,?)";
   //预处理
   $stmt = $mysqli -> prepare($sql);
   $stmt->bind_param("siss",$bookn,$bookp,$booka,$addr);
   $bookn = "计算机科学导论";
   $bookp = 11;
   $booka = "王玲";
   $addr = "清华大学出版社";
   $stmt->execute();
  
   $bookn = "建筑给水排水工程(第5版)";
   $bookp = 10;
   $booka = "王增长";
   $addr = "中国建筑工业出版社";
   $stmt -> execute();
   echo($stmt -> insert_id ."<br>");
   echo($stmt -> affected_rows);

此条目发表在db分类目录,贴了, 标签。将固定链接加入收藏夹。