实际上我已经执行了 postgres 查询,假设它返回了 10 行。现在我有了语句处理程序( $sth )。
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
print Dumper $sth->fetchrow_arrayref;
Run Code Online (Sandbox Code Playgroud)
现在,我已经从语句处理程序中获取了 5 行( $sth 。现在我想取回 $sth 指向第 1 行的引用指针......
我应该怎么办....?
谢谢
你不能这样做。数据库游标设计为像流一样逐行读取,无需倒带。
如果要跳转,则需要将数据复制到内存中的数组中。
最简单的方法是
my $all_rows = $sth->fetchall_arrayref;
Run Code Online (Sandbox Code Playgroud)
它为您提供一个 arrayref,每行一个条目,每行的格式与生成的格式相同fetchrow_arrayref。
| 归档时间: |
|
| 查看次数: |
1492 次 |
| 最近记录: |