php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77181 PDO Statement is not reusable after closing cursor on PDO OCI
Submitted: 2018-11-20 14:59 UTC Modified: -
From: morozov at tut dot by Assigned:
Status: Open Package: PDO OCI
PHP Version: 7.2.12 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
31 - 20 = ?
Subscribe to this entry?

 
 [2018-11-20 14:59 UTC] morozov at tut dot by
Description:
------------
According to the documentation PDOStatement::closeCursor() […] leaves the statement in a state that enables it to be executed again. The example below works at least with pdo_mysql, pdo_sqlite and pdo_pgsql but doesn't work with pdo_oci.

Test script:
---------------
$conn = new PDO(
    'oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=XE)))',
    'system',
    'oracle'
);

$stmt = $conn->prepare('SELECT ? FROM DUAL');
$stmt->execute([1]);
$value = $stmt->fetchColumn();
var_dump($value);

$stmt->closeCursor();

$stmt->execute([2]);
$value = $stmt->fetchColumn();
var_dump($value);


Expected result:
----------------
string(1) "1"
string(1) "2"

Actual result:
--------------
string(1) "1"
NULL


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-04 01:25 UTC] camporter1 at gmail dot com
When testing on PHP 7.2.12, the PDO statement columns remaining set after closing the cursor seems to cause the issue.

If instead closeCursor were to remove the stmt->columns (though this is probably incorrect to do), the result becomes correct because PDOStatement::execute gets past:

if (stmt->dbh->alloc_own_columns && !stmt->columns) {

so that pdo_stmt_describe_columns can be called, which will then populate the column and return 2.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 27 04:03:38 2021 UTC