sqlsrv_free_stmt

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

sqlsrv_free_stmtFrees all resources for the specified statement

说明

sqlsrv_free_stmt ( resource $stmt ) : bool

Frees all resources for the specified statement. The statement cannot be used after sqlsrv_free_stmt() has been called on it. If sqlsrv_free_stmt() is called on an in-progress statement that alters server state, statement execution is terminated and the statement is rolled back.

参数

stmt

The statement for which resources are freed. Note that null is a valid parameter value. This allows the function to be called multiple times in a script.

返回值

成功时返回 true, 或者在失败时返回 false

范例

Example #1 sqlsrv_free_stmt() 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));
}

$stmt sqlsrv_query$conn"SELECT * FROM Table_1");
if( 
$stmt === false ) {
     die( 
print_rsqlsrv_errors(), true));
}

/*-------------------------------
     Process query results here.
-------------------------------*/

/* Free the statement resources. */
sqlsrv_free_stmt$stmt);

?>

注释

The main difference between sqlsrv_free_stmt() and sqlsrv_cancel() 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.

参见

User Contributed Notes

Anonymous 19-Jan-2015 07:28
If you accidentally call this with an invalid $stmt resource, you may see unexpected fatal errors.

I had left behind a call here when cleaning up some code and this caused the my IIS server to generate an error 500 resource not found error.  Furthermore it seemed to only affect some users and not all and I could not isolate why only selected users got the error when it was called for all users.
PHP8中文手册 站长在线 整理 版权归PHP文档组所有