php pdo 验证mysql insert语法成立

Published
July 9, 2022
浏览次数 :  0

 //insert the data to chats table 
  $sql = "INSERT INTO chats (from_id,to_id,message) VALUES (?,?,?)";

  $stmt = $conn->prepare($sql);
  $res = $stmt->execute([$from_id,$to_id,$message]);

    //if the message inserted 
  if ($res) {
    // do something 
  }

Top