PHP PDO MySQL 可滚动游标不起作用 [英] PHP PDO MySQL scrollable cursor doesn't work

查看:19
本文介绍了PHP PDO MySQL 可滚动游标不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有一个包含两个字段的表:id、value.我在这个表中插入了近 10 万行.

For instance, I have a table with two fields: id, value. I've inserted almost 100k rows in this table.

我想使用可滚动光标.我写了以下代码:

I want to use scrollable cursor. I wrote the following code:

<?php
...
$sql = 'SELECT id FROM cursor_test;';
$stmt = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 3);
var_dump($row['id']); // 1, expected value is 3

我做错了什么?

推荐答案

好像mysql不支持可滚动游标.

Seems that mysql does not support scrollable cursors.

https://bugs.php.net/bug.php?id=34625

http://www.php.net/manual/en/pdostatement.fetch.php#105277

Will PDO laststatment->fetchAll(PDO::FETCH_COLUMN, $column) 每次调用都重新运行查询?

这篇关于PHP PDO MySQL 可滚动游标不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆