例如,我有一个包含两个字段的表: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 可滚动游标不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!