PDOStatement::nextRowset() - PDOStatement类
PDOStatement::nextRowset()
(PHP 5 >= 5.1.0, PHP 7, PECL pdo >= 0.2.0)
在一个多行集语句句柄中推进到下一个行集
说明
PDOStatement::nextRowset(void): bool一些数据库服务支持返回一个以上行集(也被称为结果集)的存储过程。PDOStatement::nextRowset()使你能够结合一个 PDOStatement 对象访问第二个以及后续的行集。上述的每个行集可以有不同的列集合。
返回值
成功时返回TRUE
,或者在失败时返回FALSE
。
范例
获取由一个存储过程返回的多个行集
下面例子展示了怎样调用一个存储过程,返回三个行集的 MULTIPLE_ROWSETS 。用一个 do / while 循环来循环调用PDOStatement::nextRowset()方法,当不再有行集返回时返回 false 并结束循环。
以上例程会输出:
Result set 1: apple red banana yellow Result set 2: orange orange 150 banana yellow 175 Result set 3: lime green apple red banana yellow
参见
- PDOStatement::columnCount() 返回结果集中的列数
- PDOStatement::execute() 执行一条预处理语句
- PDOStatement::getColumnMeta() 返回结果集中一列的元数据
- PDO::query() 执行 SQL 语句,以 PDOStatement 对象形式返回结果集
PDO::nextRowset() does not appear to be currently supported by the Firebird PDO driver. Unfortunate.
When you call $stmt->nextRowset(); it returns TRUE every time and does not stop with FALSE even when no more results left. It causes Fatal Error when calling $results[] = $stmt->fetchAll(PDO::FETCH_ASSOC); with error message "PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error in ..." unable to fetch result which not exists. The desission is try {} catch(e) {} $stmt = pdo->query("Call Get_multi_result();"); do { try { $streets[] = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { } } while ($stmt->nextRowset());
on MSSQL and 'dsn' => 'dblib:...',: If you know how many count rowset then don't use contruction of do..while. When I get large fetchAll(over 30) for second nextRowset. I get error - Segmentation fault. Uses step-by-step insted do..while is fix for this bug:
If you use PDO::fetch instead of PDO::fetchAll and do not reach the end the result set, PDO::nextRowset() will fail with "SQLSTATE[HY000]: General error: PDO_DBLIB: dbresults() returned FAIL."
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
免责声明:我们致力于保护作者版权,注重分享,当前被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!邮箱:344225443@qq.com)
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!
内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)