From:             michael dot caplan at lechateau dot ca
Operating system: RHE 3
PHP version:      5.0.2
PHP Bug Type:     OCI8 related
Bug description:  multiple returned lob resource being overwritten

Description:
------------
I'm not 100% sure if this is a bug, or just a 'quirk', but my attempt to
get feedback on this issue on the php db support list was unsuccessful. 
So, here I am....

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, execpt
the clob column in certain circumstances.  

Normally, with such a db return, I would loop through the results and grab
the clobs one by one.  Under 'special' circumstances, I would want to first
loop throught the results and assign the results to a new array before
fetching the clob.  This is where things get funky.  In this senario, 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).


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();
    echo $row['id'];
    // etc....
}


as expected, I get all clobs from the result set.  But in this example, I
do not:


$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)) {
    // assign all lob resources to array for later loading
    $messages[] = $row['MESSAGE'];
}

foreach ($messages as $message) {
    echo $message->load();
}


In this example, the last assigned lob resource overwrites all previous
lob resources.  When fetching the clob content later on, each record
returns the data from the last lob.  

I am pretty unawair of the internal mechanics of how resources are
handled, and this just might be a quirk of how db result resources for
oci8 are handled, and is unavoidable.  (it looks like one resource is
returned for all lobs, not multiple resources for each lob).

However, it is a pretty counter intuitive 'quirk'.  If I can loop through
the results and assign all non resource elements to an array for later
operations, should I not be able to do the same thing with resources?


Thanks.

Michael


-- 
Edit bug report at http://bugs.php.net/?id=30804&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30804&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=30804&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=30804&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30804&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30804&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30804&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30804&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30804&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30804&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30804&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=30804&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=30804&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30804&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30804&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30804&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30804&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30804&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30804&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30804&r=mysqlcfg

Reply via email to