Prepared > PHP

본문 바로가기

사이트 내 전체검색

뒤로가기 PHP

MySQLi Extension Prepared

페이지 정보

작성자 관리자 작성일 22-04-26 17:57 조회 5,421 댓글 0

본문

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();

댓글목록 0

등록된 댓글이 없습니다.

Copyright © neion.co.kr All rights reserved.
PC 버전으로 보기