mysqli_stmt::data_seek
(PHP 5, PHP 7, PHP 8)
mysqli_stmt::data_seek -- mysqli_stmt_data_seek — 명령문 결과 세트에서 임의의 행을 찾습니다.
설명
객체 지향 스타일
public mysqli_stmt::data_seek(int $offset
): void
절차적 스타일
mysqli_stmt_data_seek(mysqli_stmt $statement
, int $offset
): void
명령문 결과 집합에서 임의의 결과 포인터를 찾습니다.
mysqli_stmt_store_result()는 mysqli_stmt_data_seek()보다 먼저 호출되어야 합니다.
매개변수
statement
- 절차적 스타일 전용: mysqli_stmt_init()에 의해 반환된 mysqli_stmt 객체.
offset
- 0에서 총 행 수에서 1을 뺀 값 사이여야 합니다(0.. mysqli_stmt_num_rows() - 1).
반환 값
값이 반환되지 않습니다.
Examples
예제 #1 객체 지향 스타일
<?php
/* Open a connection */
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, CountryCode FROM City ORDER BY Name";
if ($stmt = $mysqli->prepare($query)) {
/* execute query */
$stmt->execute();
/* bind result variables */
$stmt->bind_result($name, $code);
/* store result */
$stmt->store_result();
/* seek to row no. 400 */
$stmt->data_seek(399);
/* fetch values */
$stmt->fetch();
printf ("City: %s Countrycode: %s\n", $name, $code);
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
예제 #2 절차적 스타일
<?php
/* Open a connection */
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT Name, CountryCode FROM City ORDER BY Name";
if ($stmt = mysqli_prepare($link, $query)) {
/* execute query */
mysqli_stmt_execute($stmt);
/* bind result variables */
mysqli_stmt_bind_result($stmt, $name, $code);
/* store result */
mysqli_stmt_store_result($stmt);
/* seek to row no. 400 */
mysqli_stmt_data_seek($stmt, 399);
/* fetch values */
mysqli_stmt_fetch($stmt);
printf ("City: %s Countrycode: %s\n", $name, $code);
/* close statement */
mysqli_stmt_close($stmt);
}
/* close connection */
mysqli_close($link);
?>
위의 예는 다음을 출력합니다.
City: Benin City Countrycode: NGA
기타
- mysqli_prepare() - 실행을 위해 SQL 문 준비