用PDO调用oracle存储过程,返回参数为游标,怎么提取数据

WBOY
Release: 2016-06-23 14:05:26
Original
1382 people have browsed it

有个oracle存储过程,只有一个返回参数,该参数为游标,请问用PDO组件怎么提取?

目前我写的代码如下:

$dbconn=new PDO($dsn,$user,$pwd);$strsql="begin pk001.pr001(:rc); end";$dbsear=$dbconn->prepare($strsql);$dbsear->bindParam(":rc", $rc,PDO::PARAM_LOB );$dbsear->execute();print_r($rc);
Copy after login


pk001是包名,pr001是包里面的存储过程名。rc为返回参数。

在PL/SQL工具中运行
begin pk001.pr001(rc => :rc); end;
可以看到返回值:
Variable Type Value
rc Cursor
如上的三列,最后一列点击右边的...按钮,就可以看到游标展开的数据。

请问如何用PDO将游标中的表数据,填充到一个二维数组中?


回复讨论(解决方案)

$dbsear->execute(); 后

do {  $res[] = $dbsear->fetchAll(PDF::FETCH_ASSOC); }where($dbsear->nextRowset());
Copy after login

这是通用代码
如果你的存储过程只返回一个结果集,可以去掉 do ... while 循环

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!