Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 1.73 KB

pdostatement-closecursor.md

File metadata and controls

62 lines (43 loc) · 1.73 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic
PDOStatement::closeCursor
API reference for the PDOStatement::closeCursor function in the Microsoft PDO_SQLSRV Driver for PHP for SQL Server.
David-Engel
davidengel
08/10/2020
sql
connectivity
reference

PDOStatement::closeCursor

[!INCLUDEDriver_PHP_Download]

Closes the cursor, enabling the statement to be executed again.

Syntax

  
bool PDOStatement::closeCursor();  

Return Value

true on success, otherwise false.

Remarks

closeCursor has an effect when the MultipleActiveResultSets connection option is set to false. For more information about the MultipleActiveResultSets connection option, see How to: Disable Multiple Active Resultsets (MARS).

Instead of calling closeCursor, you can also just set the statement handle to null.

Support for PDO was added in version 2.0 of the [!INCLUDEssDriverPHP].

Example

<?php  
$database = "AdventureWorks";  
$server = "(local)";  
$conn = new PDO( "sqlsrv:server=$server ; Database = $database", "", "", array('MultipleActiveResultSets' => false ) );  
  
$stmt = $conn->prepare('SELECT * FROM Person.ContactType');  
  
$stmt2 = $conn->prepare('SELECT * FROM HumanResources.Department');  
  
$stmt->execute();  
  
$result = $stmt->fetch();  
print_r($result);  
  
$stmt->closeCursor();  
  
$stmt2->execute();  
$result = $stmt2->fetch();  
print_r($result);  
?>  

See Also

PDOStatement Class

PDO