sqlsrv_send_stream_data

데이터를 매개 변수 스트림에서 서버로 전송합니다. sqlsrv_send_stream_data를 호출할 때마다 최대 8KB의 데이터가 전송됩니다.

참고

기본적으로 모든 스트림 데이터는 쿼리가 실행될 때 서버로 전송됩니다. 이 기본 동작을 변경하지 않은 경우 sqlsrv_send_stream_data을 사용하여 스트림 데이터를 서버로 전송할 필요가 없습니다. 기본 동작을 변경하는 방법은 sqlsrv_query 또는 sqlsrv_prepare의 매개 변수 단원을 참조하십시오.

구문

sqlsrv_send_stream_data( resource $stmt)

매개 변수

$stmt: 실행된 문에 해당하는 문 리소스입니다.

반환 값

부울: 전송할 데이터가 더 있는 경우 true이고 그렇지 않은 경우 false가 반환됩니다.

다음 예제에서는 제품 검토를 스트림으로 연 다음 이를 서버로 전송합니다. 실행 시 모든 스트림 데이터를 전송하는 기본 동작은 해제되어 있습니다. 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));
}

/* Define the query. */
$tsql = "UPDATE Production.ProductReview 
         SET Comments = ( ?) 
         WHERE ProductReviewID = 3";

/* Open parameter data as a stream and put it in the $params array. */
$comment = fopen( "data://text/plain,[ Insert lengthy comment.]", "r");
$params = array( &$comment);

/* Prepare the statement. Use the $options array to turn off the
default behavior, which is to send all stream data at the time of query
execution. */
$options = array("SendStreamParamsAtExec"=>0);
$stmt = sqlsrv_prepare( $conn, $tsql, $params, $options);

/* Execute the statement. */
sqlsrv_execute( $stmt);

/* Send up to 8K of parameter data to the server with each call to
sqlsrv_send_stream_data. Count the calls. */
$i = 1;
while( sqlsrv_send_stream_data( $stmt)) 
{
      echo "$i call(s) made.\n";
      $i++;
}

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

참고 항목

개념

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

관련 자료

API 참조(SQL Server Driver for PHP)
데이터 업데이트(SQL Server Driver for PHP)