Re: Unbuffered queries
| От | Mark Kirkwood |
|---|---|
| Тема | Re: Unbuffered queries |
| Дата | |
| Msg-id | 52D25955.4050909@catalyst.net.nz обсуждение исходный текст |
| Ответ на | Re: Unbuffered queries (Eric Chamberlain <eric.chamberlain@hotmail.com>) |
| Список | pgsql-php |
On 09/01/14 18:33, Eric Chamberlain wrote:
> Correct. I ended up limiting the number of records I query at a time.
> I'm not sure how much of the thread has been e-mailed to you but I have
> an example that shows the method in which I was able to query N number
> of records every iteration.
>
Unfortunately I don't seem to have seen that message. However that
reminds me that for completeness I should really show an example
fetching >1 row at a time in PDO (pgbench schema again):
$fetch_num = 100;
$cursql = "DECLARE cur1 CURSOR FOR SELECT * FROM pgbench_accounts
WHERE bid = ?";
$sql = "FETCH $fetch_num FROM cur1";
$dbh->beginTransaction();
$curstmt = $dbh->prepare($cursql);
$curstmt->execute(array(rand(0, 100)));
for (;;) {
$stmt = $dbh->prepare($sql);
$stmt->execute();
$rowarray = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rowarray) {
foreach ($rowarray as $row) {
print "... " . $row['aid'] . " " . $row['bid'] . "\n";
}
} else {
break;
}
}
Regards
Mark
В списке pgsql-php по дате отправления: