Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdo_oci poiting all records to the last resource blob when using fetchAll #15967

Open
diogotoscano opened this issue Sep 20, 2024 · 2 comments
Open

Comments

@diogotoscano
Copy link

diogotoscano commented Sep 20, 2024

Description

The following code:

<?php

$pdo = new PDO("oci:dbname=xxx.xxx.xxx.xxx/xxxxx", "xxxx",   "xxxxx);
$pdo->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

//doesnt work 
$stm = $pdo->query("SELECT PICTURE FROM USU_19013.CATEGORIES");
foreach($stm->fetchAll(PDO::FETCH_NUM ) as $row)
{
    if(is_resource($row[0]))
    {
        $blob = stream_get_contents($row[0]);
        echo strlen($blob);
    }
    echo "<br>";
}

echo "-----------------------------------<br>";

//works
$stmt = $pdo->query("SELECT PICTURE FROM USU_19013.CATEGORIES");
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {

    $blob = stream_get_contents($row[0]);
    echo strlen($blob);
    echo "<br>";
}

Resulted in this output:

6592
6592
6592
6592
6592
6592
6592
6592
-----------------------------------
805361
12984
29416
6768
9104
16652
8864
6592

But I expected this output instead:

805361
12984
29416
6768
9104
16652
8864
6592
-----------------------------------
805361
12984
29416
6768
9104
16652
8864
6592

PHP Version

8.1.28

Operating System

Windows NT DESKTOP-VKLN5U7 10.0 build 22631 (Windows 11) AMD64

@cmb69
Copy link
Member

cmb69 commented Sep 21, 2024

Does this also happen with any of the actively supported PHP versions, (i.e. PHP 8.2 or PHP 8.3)?

@diogotoscano
Copy link
Author

Does this also happen with any of the actively supported PHP versions, (i.e. PHP 8.2 or PHP 8.3)?

Same output with:
PHP Version 8.2.12
PHP Version 8.3.11 - Aug 27 2024 21:26:18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants