mysql_data_seek pdo equivalent(mysql_data_seek pdo 等价物)
问题描述
mysql_data_seek 使用 pdo 对象的等价物是什么?可以举个例子吗?
Which is the equivalent of mysql_data_seek using pdo objects? Can you give me an example?
谢谢!
推荐答案
通常的答案是:直接在数组中查找数据 PDOStatement::fetchAll... 但是如果查询获取了大量数据(!).
The usual answer is: do your data seek directly in the array PDOStatement::fetchAll... But it is WRONG IF the query fetches a lot of data (!).
有两个真正的解决方案,
There are 2 real solutions,
1) 如果数据库允许使用 PDO::FETCH_ORI_ABS 或 PDO::FETCH_ORI_REL,例如,
1) if database permits use PDO::FETCH_ORI_ABS or PDO::FETCH_ORI_REL,
example,
$result = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 973);
(编辑)但是,正如@ChoiZ 所评论的,有一个 PDO-MySQL 限制:MySQL 不支持cursors"(外部存储程序)并且驱动程序无法为您模拟它们"......稍后尝试或使用 MySQL 的分支,如 MariaDB.
(EDIT) But, as commented by @ChoiZ, have a PDO-MySQL limitation: "MySQL does not support cursors" (outside stored programs) "and the driver cannot emulate them for you"... Try later or with MySQL's forks, like MariaDB.
2) 使用数据库解决方案(一种分页).示例:
2) use the database solution (a kind of pagination). Example:
SELECT a, b FROM table LIMIT 1, 973
这篇关于mysql_data_seek pdo 等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mysql_data_seek pdo 等价物
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
