How does one obtain Resourceid from multiple returned values when pdo connects to oracle to read data?

Source: Internet
Author: User
After connecting to the oracle database with pdo, obtain multiple pieces of article data. The returned value contains Resourceid. How can I obtain this content? {Code ...} try this way, but the last piece of data is obtained. {code ...} instead of using fetchAll to use fetch, the number of obtained results is always... after connecting to the oracle database with pdo, obtain multiple pieces of article data. The returned value contains the Resource id. How can I obtain the content?

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

This is an attempt, but the last piece of data is obtained.

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

Instead of using fetchAll to use fetch, there is a problem with the number of obtained results. For example, 3 results are output only when 10 results are obtained in an SQL statement.

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

Reply content:

After connecting to the oracle database with pdo, obtain multiple pieces of article data. The returned value contains the Resource id. How can I obtain the content?

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

This is an attempt, but the last piece of data is obtained.

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

Instead of using fetchAll to use fetch, there is a problem with the number of obtained results. For example, 3 results are output only when 10 results are obtained in an SQL statement.

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

  1. The last piece of data is obtained. This is a known bug. It has been discussed in php and has no solution.

  2. Is fetch only returns one field? When I use cyclic fetch, it is still 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. Even if this problem is solved, the problem of output parameters cannot be bypassed when the stored procedure is called. Avoid using oracle pdo whenever possible.

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.