[PHP-NOTES] note 130643 added to pdostatement.closecursor

[email protected] ("[email protected]") Fri, 06 Feb 2026 19:01:17 +0000
Newsgroups php.notes
Message-ID <[email protected]>
This is pretty useful when using PDO with MySQL after executing a stored procedure:

<?php

// PDO Connection Defintion

$query = "call custom_procedure()";
$stmt = $conn->query($query);

// Error checking

$stmt->fetch();

$stmt->closeCursor();
// Not calling closeCursor will error the query below as
// 2014 - Cannot execute queries while there are pending result sets.

$query = "select * from table";
$stmt = $conn->query($query);
----
Server IP: 206.189.2.9
Probable Submitter: 190.151.1.170
----
Manual Page -- https://php.net/manual/en/pdostatement.closecursor.php
Edit        -- https://main.php.net/note/edit/130643
Del: integrated  -- https://main.php.net/note/delete/130643/integrated
Del: useless     -- https://main.php.net/note/delete/130643/useless
Del: bad code    -- https://main.php.net/note/delete/130643/bad+code
Del: spam        -- https://main.php.net/note/delete/130643/spam
Del: non-english -- https://main.php.net/note/delete/130643/non-english
Del: in docs     -- https://main.php.net/note/delete/130643/in+docs
Del: other reasons-- https://main.php.net/note/delete/130643
Reject      -- https://main.php.net/note/reject/130643
Search      -- https://main.php.net/manage/user-notes.php