有人知道pg-result-seek的PDO等价物吗?我想使用 Postgre 倒带数据集。
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] 将包含您要查找的行。
如果数据库允许,请使用 PDO::FETCH_ORI_ABS 或 PDO::FETCH_ORI_REL,
例如。
$result = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 671);
这是fetch
函数的一部分:http://www.php.net/manual/en/pdostatement.fetch.php
但我不认为有必要这样做,如果您选择行,则需要它(全部)......