php pdo 验证mysql insert语法成立

Published
2022-07-09
浏览次数 :  177

 //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 
  }

  • 标签1
  • 标签1
  • 标签1
Top