English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
mysqli_stmt_free_result() 함수는 주어진 문장 핸들의 저장된 결과 메모리를 해제합니다.
mysqli_stmt_free_result();함수는(준비된)문장 객체를 파라미터로 받아 주어진 문장의 결과를 저장한 메모리를 해제합니다(mysqli_stmt_store_result() 함수로 결과를 저장할 때 사용됩니다).
mysqli_stmt_free_result($stmt);
순번 | 파라미터 및 설명 |
---|---|
1 | con(필수) 이는 준비된 문장의 객체를 나타냅니다. |
PHP mysqli_stmt_free_result() 함수는 어떤 값을 반환하지 않습니다.
이 함수는 초기로 PHP 버전5중에서 도입되었으며 모든 더 높은 버전에서 사용할 수 있습니다.
다음 예제에서는 다음과 같이 표현됩니다:mysqli_stmt_free_result();함수의 사용법(과정 지향 스타일), 결과 해제 후의 행 수를 반환합니다:
<?php $con = mysqli_connect("localhost", "root", "password", "mydb"); mysqli_query($con, "CREATE TABLE Test(Name VARCHAR(255), AGE INT)"); mysqli_query($con, "insert into Test values('Raju', 25),('Rahman', 30),('Sarmista', 27)"); print("테이블 생성.....\n"); //레코드 읽기 $stmt = mysqli_prepare($con, "SELECT * FROM Test"); //문장 실행 mysqli_stmt_execute($stmt); //결과 저장 mysqli_stmt_store_result($stmt); //행 수 $count = mysqli_stmt_num_rows($stmt); print("테이블의 행 수: ".$count."\n"); //결과 집합 해제 mysqli_stmt_free_result($stmt); $count = mysqli_stmt_num_rows($stmt); print("결과 해제 후의 행 수: ".$count."\n"); //문장 종료 mysqli_stmt_close($stmt); //연결 닫기 mysqli_close($con); ?>
결과 출력
테이블 생성..... 테이블의 행 수: 3 결과 해제 후의 행 수: 0
객체 지향 스타일에서 이 함수의 문법은 다음과 같습니다$stmt->free_result();。이 함수의 객체 지향 스타일 예제는 다음과 같습니다;
<?php //연결 설정 $con = new mysqli("localhost", "root", "password", "mydb"); $con -> query("CREATE TABLE Test(Name VARCHAR(255), AGE INT)"); $con -> query("insert into Test values('Raju', 25),('Rahman', 30),('Sarmista', 27)"); print("테이블 생성.....\n"); $stmt = $con -> prepare( "SELECT * FROM Test"); //문장 실행 $stmt->execute(); //결과 저장 $stmt->store_result(); print("저장된 결과 행 수: ".$stmt ->num_rows); //결과 집합 메모리 해제 $stmt->free_result(); //문장 종료 $stmt->close(); //연결 닫기 $con->close(); ?>
결과 출력
테이블 생성..... 저장된 결과 행 수: 3