php

2022.04.26 17:57

Prepared

public mysqli_stmt::bind_param(string $types, mixed &$var, mixed &...$vars): bool 


types

A string that contains one or more characters which specify the types for the corresponding bind variables:

Type specification chars
CharacterDescription
icorresponding variable has type integer
dcorresponding variable has type double
scorresponding variable has type string
bcorresponding variable is a blob and will be sent in packets


// prepare and bind

$stmt = $mysqli->prepare("INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)");

$stmt->bind_param("sss", $firstname, $lastname, $email);


// set parameters and execute

$firstname = "John";

$lastname = "Doe";

$email = "john@example.com";

$stmt->execute();


$firstname = "Mary";

$lastname = "Moe";

$email = "mary@example.com";

$stmt->execute();


$firstname = "Julie";

$lastname = "Dooley";

$email = "julie@example.com";

$stmt->execute();


echo "New records created successfully";


$stmt->close();

  • 공유링크 복사
  • 다음글Insert Multiple2022.04.26
  • 댓글목록

    등록된 댓글이 없습니다.