pg_result_seek
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
pg_result_seek — 在 result 实例中设定内部行偏移量
参数
result
-
PgSql\Result 实例,由 pg_query()、pg_query_params() 或者 pg_execute()(等)返回。
row
-
在 PgSql\Result 实例中将内部偏移量移动到的行。行号从零开始。
更新日志
版本 | 说明 |
---|---|
8.1.0 |
现在 result 参数接受 PgSql\Result
实例,之前接受 resource。
|
示例
示例 #1 pg_result_seek() 示例
<?php
// 连接到数据库
$conn = pg_pconnect("dbname=publisher");
// 执行查询
$result = pg_query($conn, "SELECT author, email FROM authors");
// 寻找第三行(假设有 3 行)
pg_result_seek($result, 2);
// 获取第三行记录
$row = pg_fetch_row($result);
?>
参见
- pg_fetch_row() - 提取一行作为枚举数组
- pg_fetch_assoc() - 获取一行作为关联数组
- pg_fetch_array() - 获取一行作为数组
- pg_fetch_object() - 获取一行作为对象
- pg_fetch_result() - 从结果实例返回值
+添加备注
用户贡献的备注 1 note
andrew-php dot net at andrew dot net dot au ¶
20 years ago
Ah, this is a handy feature for resetting the record index, for example, if you're used pg_fetch_{row,array,assoc} to iterate over the result set, and you want to do it again later on, without reexecuting your query. Something like:
<?php pg_result_seek($result, 0); ?>
will allow you to iterate over the result set all over again...
备份地址:http://www.lvesu.com/blog/php/function.pg-result-seek.php