multiple returned lob resource being overwritten in oci8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
 
I am selecting multiple columns from a table, one being a clob.  the
query returns multiple records for the query.  The results are all good,
except the clob column.  The last returned record's clob column
overwrites all previous clob columns (all the previous records have
there unique data, except the clob columns which contains the data for
the last record across all previous records), depending on how I fetch the
data.
 
A working example:
 
$query = 'select 
                id,
                author,
                cdate,
                views,
                title,
                message,
                top
            from 
                APP_THREADS 
            where 
                TYPE = \'D\'';
$stmt = ociparse($fw_db->connection, $query);
ociexecute($stmt);
 
while (OCIFetchInto ($stmt, $row, OCI_ASSOC)) {
    echo $row['MESSAGE']->load();
}
 
with the output being something like this:
 
clob1
clob2
clob3
clob4
 
 
All good.  But, if I don't grap the lob output right away, and do some other
assignement work on the result before hand, the above explained issue takes
shape. The issue, after some testing, appears to be how the oci8 function
stores the clob resource.  The following code results in this problem:
 
$query = 'select 
                id,
                author,
                cdate,
                views,
                title,
                message,
                top
            from 
                APP_THREADS 
            where 
                TYPE = \'D\'';
 
$stmt = ociparse($fw_db->connection, $query);
ociexecute($stmt);
 
while (OCIFetchInto ($stmt, $row, OCI_ASSOC)) {
    $messages[] = $row['MESSAGE'];
}
 
foreach ($messages as $message) {
    var_dump($message->load());
}
 
with the output being:
clob4
clob4
clob4
clob4
 
In this example the lob resources are overwritten when you loop through
the result set the first time around, resulting in all fetched lobs
returning the value of the last lob in the result set.
 
 
 
The question is: is this an oci8 bug or just how things have to be done?
 
 
Thanks,
 
Michael

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux