PHP PDO MySQL scrollable cursor doesn't work

别来无恙 提交于 2019-11-28 02:03:35

问题


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

What am I doing wrong?


回答1:


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) rerun the query each call?



来源:https://stackoverflow.com/questions/12044636/php-pdo-mysql-scrollable-cursor-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!