例如,我有一个包含两个字段的表: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 可滚动游标不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
PHP、MySQL PDOException 的死锁异常代码?Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死锁异常代码?)
PHP PDO ODBC 连接PHP PDO ODBC connection(PHP PDO ODBC 连接)
使用 PDO::FETCH_CLASS 和魔术方法Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔术方法)
php pdo 只从 mysql 获取一个值;等于变量的值php pdo get only one value from mysql; value that equals to variable(php pdo 只从 mysql 获取一个值;等于变量的值)
MSSQL PDO 找不到驱动程序MSSQL PDO could not find driver(MSSQL PDO 找不到驱动程序)
PDO 连接从命令行工作,而不是通过 Apache?PDO connection works from command line, but not through Apache?(PDO 连接从命令行工作,而不是通过 Apache?)