ID:               30804
 User updated by:  michael dot caplan at lechateau dot ca
 Reported By:      michael dot caplan at lechateau dot ca
-Status:           No Feedback
+Status:           Open
 Bug Type:         OCI8 related
 Operating System: RHE 3
 PHP Version:      5.0.2
 Assigned To:      tony2001
 New Comment:

Did this fix make it into PHP 5.0.4 (didn't see it in the change log),
or do I need to install a latest snap?


Previous Comments:
------------------------------------------------------------------------

[2005-04-02 01:00:28] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2005-03-25 01:38:43] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2004-11-16 14:48:26] michael dot caplan at lechateau dot ca

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 this bug report at http://bugs.php.net/?id=30804&edit=1

Reply via email to