PHP stream_get_contents()从数据库中读取LOB的行为很奇怪

I have 2 records in a table with similar CLOB data. Each of those are parsed from a query and then read into a string by php in a loop against the returned PDO::FETCH_ASSOC

it looks something like this after the query returns the results:

ID   |   NAME   |   DESCRIPTION   |   LOB_DEFINITION
4409     foo        blah blah         long text that is stored in a lob ~ 5k characters
4410     foobar     blah blah         some other long text stored in a lob ~ 5k characters

My problem is that once I start looping through this and reading contents from the LOBs they don't 'reset' So, any and all of the objects read will have the same values as the first LOB it read:

something like this:

foreach($result as $r) {
$lob = stream_get_contents($r['LOB_DEFINITION']);
echo $r['ID'].'-<i>'.$lob.'</i><HR>';
unset($lob);
}

results in output that looks like this:

4409-long text that is stored in a lob ~ 5k characters


4410-long text that is stored in a lob ~ 5k characters

instead of what I would expect to get which would be:

4409-long text that is stored in a lob ~ 5k characters


4410-some other long text stored in a lob ~ 5k characters

I've checked the Resource IDs as well and they are different resources...

I'm at a loss here... Does anyone have insight on this subject?

Several hours of research resulted in the following:

returning a multi-record set from an oracle table where one of the columns is a clob datatype will result in the last record retrieved clob to be the value for ALL clobs retrieved. This is what was causing the behavior above.

What I ended up doing to solve the issue was first:

selecting all the records in which I planned to work with clobs (not the clobs themselves, just the record IDs)

I then loop through those record IDs and with separate database calls process the CLOB data 1 by 1 using the primary key to pull in the record to ensure no more than 1 record comes back with clob data. So in essence here is what is happening now:

after retrieving the ID from the table for all clobs I want to work with I parse through them thusly:

foreach($result as $r) {
  $query = 'select lob_definition from mytable where id = '.$r;
  $lobresult = oracleConnection->query($query)->fetchAll(FETCH_COLUM);
    $lob = stream_get_contents($lobresult);
    echo $r['ID'].'-<i>'.$lob.'</i><HR>';
    unset($lob);
}

something to that effect has solved my problem (all of it is abstracted in various methods, but essentially that's what is happening.