sqlsrv_next_result

(No version information available, might only be in Git)

sqlsrv_next_resultMakes the next result of the specified statement active

说明

sqlsrv_next_result ( resource $stmt ) : mixed

Makes the next result of the specified statement active. Results include result sets, row counts, and output parameters.

参数

stmt

The statement on which the next result is being called.

返回值

Returns TRUE if the next result was successfully retrieved, FALSE if an error occurred, and NULL if there are no more results to retrieve.

范例

Example #1 sqlsrv_next_result() example

The following example executes a batch query that inserts into a table and then selects from the table. This produces two results on the statement: one for the rows affected by the INSERT and one for the rows returned by the SELECT. To get to the rows returned by the SELECT, sqlsrv_next_result() must be called to move past the first result.

<?php
$serverName 
"serverName\sqlexpress";
$connectionInfo = array("Database"=>"dbName""UID"=>"userName""PWD"=>"password");
$conn sqlsrv_connect$serverName$connectionInfo);

$query "INSERT INTO Table_1 (id, data) VALUES (?,?); SELECT * FROM TABLE_1;";
$params = array(1"some data");
$stmt sqlsrv_query($conn$query$params);

// Consume the first result (rows affected by INSERT) without calling sqlsrv_next_result.
echo "Rows affected: ".sqlsrv_rows_affected($stmt)."<br />";

// Move to the next result and display results.
$next_result sqlsrv_next_result($stmt);
if( 
$next_result ) {
   while( 
$row sqlsrv_fetch_array$stmtSQLSRV_FETCH_ASSOC)){
      echo 
$row['id'].": ".$row['data']."<br />"
   }
} elseif( 
is_null($next_result)) {
     echo 
"No more results.<br />";
} else {
     die(
print_r(sqlsrv_errors(), true));
}
?>

参见

相关文章
php cubrid 函数 get result of next query when executing multiple sql statementsphp ibm db2 函数 sets the result set pointer to the next row or requested rowphp ibm db2 函数 requests the next result set from a stored procedurephp frontbase 函数 get the type of the specified field in a resultphp maxdb 函数 set result pointer to a specified field offsetphp maxdb 函数 prepare next result from multi queryphp maxdb 函数 seeks to an arbitray row in statement result setphp maxdb 函数 frees stored result memory for the given statement handlephp oci8 函数 returns the next child statement resource from a parent statement resource that has oracle database 12c implicit result setsphp postgresql 函数 sends a request to execute a prepared statement with given parameters without waiting for the result s php sqlite 函数 fetches the next row from a result set as an objectphp sqlsrv 函数 executes a statement prepared with sqlsrv preparephp sqlsrv 函数 retrieves the next row of data in a result set as an objectphp sqlsrv 函数 makes the next row in a result set available for readingphp sqlsrv 函数 retrieves metadata for the fields of a statement prepared by sqlsrv prepare or sqlsrv queryphp sqlsrv 函数 frees all resources for the specified statementphp sqlsrv 函数 indicates whether the specified statement has rowsphp sqlsrv 函数 makes the next result of the specified statement activephp mysql xdevapi statement get next resultphp swish 函数 get the next search result
关注编程学问公众号