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?
egemadra
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