sqlsrv_cancel

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

sqlsrv_cancelCancels a statement

说明

sqlsrv_cancel ( resource $stmt ) : bool

Cancels a statement. Any results associated with the statement that have not been consumed are deleted. After sqlsrv_cancel() has been called, the specified statement can be re-executed if it was created with sqlsrv_prepare(). Calling sqlsrv_cancel() is not necessary if all the results associated with the statement have been consumed.

参数

stmt

The statement resource to be cancelled.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

Example #1 sqlsrv_cancel() example

<?php
$serverName 
"serverName\sqlexpress";
$connectionInfo = array( "Database"=>"dbName""UID"=>"username""PWD"=>"password");
$conn sqlsrv_connect$serverName$connectionInfo);
if( 
$conn === false ) {
     die( 
print_rsqlsrv_errors(), true));
}

$sql "SELECT Sales FROM Table_1";

$stmt sqlsrv_prepare$conn$sql);

if( 
$stmt === false ) {
     die( 
print_rsqlsrv_errors(), true));
}

if( 
sqlsrv_execute$stmt ) === false) {
     die( 
print_rsqlsrv_errors(), true));
}

$salesTotal 0;
$count 0;

while( (
$row sqlsrv_fetch_array$stmt)) && $salesTotal <=100000)
{
     
$qty $row[0];
     
$price $row[1];
     
$salesTotal += ( $price $qty);
     
$count++;
}

echo 
"$count sales accounted for the first $$salesTotal in revenue.<br />";

// Cancel the pending results. The statement can be reused.
sqlsrv_cancel$stmt);
?>

注释

The main difference between sqlsrv_cancel() and sqlsrv_free_stmt() is that a statement resource cancelled with sqlsrv_cancel() can be re-executed if it was created with sqlsrv_prepare(). A statement resource cancelled with sqlsrv_free_statement() cannot be re-executed.

参见

相关文章
php cubrid mysql 兼容性函数 escape special characters in a string for use in an sql statementphp ibm db2 函数 executes a prepared sql statementphp ibm db2 函数 retrieves an option value for a statement resource or a connection resourcephp maxdb 函数 closes a prepared statementphp maxdb 函数 transfers a result set from a prepared statementphp odbc 函数 prepare and execute an sql statementphp postgresql 函数 sends a request to execute a prepared statement with given parameters without waiting for the result s php sqlsrv 函数 cancels a statementphp sqlsrv 函数 opens a connection to a microsoft sql server databasephp sqlsrv 函数 returns error and warning information about the last sqlsrv operation performedphp sqlsrv 函数 executes a statement prepared with sqlsrv preparephp 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 sqlsrv 函数 retrieves the number of fields columns on a statementphp sqlsrv 函数 rolls back a transaction that was begun with sqlsrv begin transactionphp sqlsrv 函数 returns the number of rows modified by the last insert update or delete query executedphp sqlsrv 函数 sends data from parameter streams to the serverphp sdo das relational 函数 executes an sql query passed as a prepared statement with a list of values to substitute for placeholders and return the results as a normalised data graph
关注编程学问公众号