Re: Unbuffered queries

From: Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>
To: Eric Chamberlain <eric(dot)chamberlain(at)hotmail(dot)com>, Andrew McMillan <andrew(at)morphoss(dot)com>
Cc: "pgsql-php(at)postgresql(dot)org" <pgsql-php(at)postgresql(dot)org>
Subject: Re: Unbuffered queries
Date: 2014-01-12 08:59:01
Message-ID: 52D25955.4050909@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Archana K N 2014-01-17 08:28:26 UPDATE (SELECT ) is not working................
Previous Message Eric Chamberlain 2014-01-09 05:33:53 Re: Unbuffered queries