Skip to content

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

Open
@diogotoscano

Description

@diogotoscano

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions