Share via


sqlsrv_send_stream_data

Scaricare il driver PHP

Invia dati da flussi di parametri al server. Con ogni chiamata a sqlsrv_send_stream_data vengono inviati fino a otto kilobyte (8 KB) di dati.

Nota

Per impostazione predefinita, tutti i dati di flusso vengono inviati al server quando viene eseguita una query. Se questo comportamento predefinito non viene modificato, non è necessario usare sqlsrv_send_stream_data per inviare dati di flusso al server. Per informazioni sulla modifica del comportamento predefinito, vedere la sezione Parametri di sqlsrv_query o sqlsrv_prepare.

Sintassi

  
sqlsrv_send_stream_data( resource $stmt)  

Parametri

$stmt: risorsa di istruzione corrispondente a un'istruzione eseguita.

Valore restituito

Valore booleano: true se sono presenti altri dati da inviare. In caso contrario, false.

Esempio

L'esempio seguente apre una revisione del prodotto sotto forma di flusso e lo invia al server. Il comportamento predefinito di invio di tutti i dati di flusso in fase di esecuzione è disabilitato. Nell'esempio si presuppone che SQL Server e il database AdventureWorks siano installati nel computer locale. Quando si esegue l'esempio dalla riga di comando, tutto l'output viene scritto nel browser.

<?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. */
$data = 'Insert any lengthy comment here.';
$comment = fopen('data:text/plain,'.urlencode($data), '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);  
?>  

Vedere anche

Riferimento all'API del driver SQLSRV

Aggiornamento dei dati (Driver Microsoft per PHP per SQL Server)

Informazioni sugli esempi di codice nella documentazione