略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: sqlsrv_cancel

2024-11-14

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

范例

示例 #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.

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.sqlsrv-cancel.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3