PDO 的游标为何无效?

baidu_26094577 2015-02-27 02:49:49
			$aa = $db->prepare('select * from user',array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$aa ->execute();
$aa->fetch();
$aa->fetch();
$a=$aa->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT);
print_r($a);


prepare中已经设置了开启游标;
结果是第三行,而不是最后一行;
测试了所有的fetch第二个参数,均无效;

求问这是什么原因,这个又不是回滚,需要表是INNODB吗?
按照手册上的写法,也不好用,很是费解;
求助中....thinks;
...全文
138 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2015-02-28
  • 打赏
  • 举报
回复
FETCH_ORI_NEXT Fetch the next row in the result set. Valid only for scrollable cursors. 取下一行的结果集 FETCH_ORI_PRIOR Fetch the previous row in the result set. Valid only for scrollable cursors. 取前一行的结果集 FETCH_ORI_FIRST (integer) Fetch the first row in the result set. Valid only for scrollable cursors. 取结果集中的第一行 FETCH_ORI_LAST Fetch the last row in the result set. Valid only for scrollable cursors. 取最后一行的结果集 FETCH_ORI_ABS Fetch the requested row by row number from the result set. Valid only for scrollable cursors. 获取所请求的行数从结果集 FETCH_ORI_REL Fetch the requested row by relative position from the current position of the cursor in the result set. Valid only for scrollable cursors. 获取所请求的行从结果中光标当前位置的相对位置的设置
tottyandbaty 2015-02-28
  • 打赏
  • 举报
回复
当然是第三行记录啦,你仔细看看手册上的例子以及函数的说明

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧