sqlsrv_free_stmt

지정된 문과 연관된 모든 리소스를 해제합니다. 이 함수를 호출한 후에는 문을 다시 사용할 수 없습니다.

구문

sqlsrv_free_stmt( resource $stmt)

매개 변수

$stmt: 닫으려는 문입니다.

반환 값

잘못된 매개 변수를 사용하여 함수를 호출한 경우가 아니면 부울 값 true가 반환되고 잘못된 매개 변수를 사용하여 함수를 호출한 경우 false가 반환됩니다.

참고

Null은 이 함수의 유효한 매개 변수로서 스크립트에서 함수를 여러 번 호출할 수 있도록 해 줍니다. 예를 들어, 오류 조건에서 문을 해제하고 스크립트 끝부분에서 문을 다시 해제하는 경우 오류 조건의 첫 번째 sqlsrv_free_stmt 호출에서 문 리소스가 null로 설정되므로 두 번째 sqlsrv_free_stmt 호출에서 true가 반환됩니다.

다음 예제에서는 문 리소스를 만들고 간단한 쿼리를 실행한 다음 sqlsrv_free_stmt를 호출하여 문과 연관된 모든 리소스를 해제합니다. SQL Server와 AdventureWorks 데이터베이스가 로컬 컴퓨터에 설치되어 있다고 가정합니다. 명령줄에서 이 예제를 실행하면 모든 출력이 콘솔에 기록됩니다.

<?php
/* Connect to the local server using Windows Authentication and
specify the AdventureWorks database as the database in use. */
$serverName = "(local)";
$connectionInfo = array( "Database"=>"AdventureWorks");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
     echo "Could not connect.\n";
     die( print_r( sqlsrv_errors(), true));
}

$stmt = sqlsrv_query( $conn, "SELECT * FROM Person.Contact");
if( $stmt )
{
     echo "Statement executed.\n";
}
else
{
     echo "Query could not be executed.\n";
     die( print_r( sqlsrv_errors(), true));
}

/*-------------------------------
     Process query results here.
-------------------------------*/

/* Free the statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>

참고 항목

참조

sqlsrv_cancel

개념

설명서에 포함된 코드 예제 정보

관련 자료

API 참조(SQL Server Driver for PHP)