2

有人知道pg-result-seek的 PDO 等价物吗?我想使用 Postgre 倒带数据集。

4

3 回答 3

1

如果数据库允许,使用 PDO::FETCH_ORI_ABS 或 PDO::FETCH_ORI_REL,

例如。

$result = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 671);
于 2013-10-18T20:25:01.023 回答
1

这是fetch功能的一部分: http ://www.php.net/manual/en/pdostatement.fetch.php

但是我认为没有必要这样做,如果您选择行,则需要它(全部)...

于 2013-10-18T20:19:14.773 回答
1

PDO 的query()方法将返回一个PDOStatement Object。没有像您要求的那样寻求特定记录的等价物。一种替代方法可能是使用fetchAll()方法,然后获取您要查找的第 N 条记录。

<?php
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();

/* Fetch all of the remaining rows in the result set */
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();
print_r($result);

$result[N] 将包含您要查找的行。

于 2013-10-18T20:19:49.790 回答