PDO connects Oracle to read data, and how does the resource ID in multiple return values get?

Source: Internet
Author: User
After using PDO to connect to an Oracle database, get multiple article data, and the return value contains the resource ID, how do you get the content?

$data_f = $ocl->query($sql);print_r($data = $data_f->fetchAll(PDO::FETCH_ASSOC));

Try this, but all you get is the content of the last piece of data

foreach($data as $v){    echo stream_get_contents($v['CONTENT']);}

Instead of using Fetchall instead of a fetch, the number of fetched bars is problematic, for example, 10 in SQL statements, only output 3

while($v = $data_f->fetch(PDO::FETCH_ASSOC)){    echo stream_get_contents($v['CONTENT']);}

Reply content:

After using PDO to connect to an Oracle database, get multiple article data, and the return value contains the resource ID, how do you get the content?

$data_f = $ocl->query($sql);print_r($data = $data_f->fetchAll(PDO::FETCH_ASSOC));

Try this, but all you get is the content of the last piece of data

foreach($data as $v){    echo stream_get_contents($v['CONTENT']);}

Instead of using Fetchall instead of a fetch, the number of fetched bars is problematic, for example, 10 in SQL statements, only output 3

while($v = $data_f->fetch(PDO::FETCH_ASSOC)){    echo stream_get_contents($v['CONTENT']);}

    1. Get to the last piece of data, this is a known bug, in PHP has been discussed, no solution

    2. Fetch there, is it because fetch only returns a field? When I use the loop fetch, it's normal.

My current code is:
`

    while($row=$pStmt->fetch(PDO::FETCH_ASSOC)){                $clobFields=$this->detectClob($row);                if(count($clobFields)>0){                    $this->retriveClobRow($row,$clobFields);                }                $rst[]=$row;            }                protected function retriveClobRow(&$row,$clobFields){        if(count($clobFields)>0){            foreach($clobFields as $colName){                $row[$colName] =stream_get_contents($row[$colName]);            }        }    }            `

All in all, Oracle PDO is a small toy, and even if the problem is solved, there are problems with the output parameters when calling the stored procedure. Try to avoid using Oracle PDO.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.