mysql_data_seek pdo 等价物 [英] mysql_data_seek pdo equivalent

查看:19
本文介绍了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_ABSPDO::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 等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆