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']);}
Get to the last piece of data, this is a known bug, in PHP has been discussed, no solution
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.