mysqli_stmt_param_count
(PHP 5, PHP 7, PHP 8)
mysqli_stmt::$param_count -- mysqli_stmt_param_count — 주어진 명령문에 대한 매개변수의 수를 반환
설명
객체 지향 스타일
int $mysqli_stmt->param_count;
절차적 스타일
mysqli_stmt_param_count(mysqli_stmt $statement
): int
준비된 명령문에 있는 매개변수 마커의 수를 리턴합니다.
매개변수
statement
- 절차적 스타일 전용: mysqli_stmt_init()에 의해 반환된 mysqli_stmt 객체.
반환 값
매개변수의 수를 나타내는 정수를 반환합니다.
Examples
예제 #1 객체 지향 스타일
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($stmt = $mysqli->prepare("SELECT Name FROM Country WHERE Name=? OR Code=?")) {
$marker = $stmt->param_count;
printf("Statement has %d markers.\n", $marker);
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
예제 #2 절차적 스타일
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($stmt = mysqli_prepare($link, "SELECT Name FROM Country WHERE Name=? OR Code=?")) {
$marker = mysqli_stmt_param_count($stmt);
printf("Statement has %d markers.\n", $marker);
/* close statement */
mysqli_stmt_close($stmt);
}
/* close connection */
mysqli_close($link);
?>
위의 예는 다음을 출력합니다.
Statement has 2 markers.
기타
- mysqli_prepare() - 실행을 위해 SQL 문 준비