- i corresponding variable has type integer
- d corresponding variable has type double
- s corresponding variable has type string
- b corresponding variable is a blob and will be sent in packets
insert, update, delete
$sql = "insert into user(id,name,lastname) values (?,?,?)"; // param ให้แทนด้วย ?
$stmt = $conn->prepare($sql);
$stmt->bind_param("iss", $id, $name, $lastname);// bind_param ต้องใส่ชนิด param ลงไปด้วย
$id=1;
$name = "abc";
$lastname = "cde";
if ($stmt->execute()) {
echo $stmt->insert_id;
$stmt->close();
} else {
echo $stmt->error;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น