1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-12-11 17:09:39 +01:00
ext-pq/tests/unbuffered001.phpt

59 lines
822 B
Plaintext
Raw Normal View History

2013-02-14 14:54:22 +01:00
--TEST--
unbuffered result
--SKIPIF--
<?php include "_skipif.inc"; ?>
--FILE--
<?php
echo "Test\n";
include "_setup.inc";
$c = new pq\Connection(PQ_DSN);
var_dump($c->unbuffered ? true : false);
$c->unbuffered = 1;
var_dump($c->unbuffered);
$c->execAsync("SELECT a from generate_series(1,10) a", function($res) {
switch ($res->status) {
case pq\Result::SINGLE_TUPLE:
$res->fetchCol("a", $val);
printf("%s\n", $val);
2013-02-14 14:54:22 +01:00
break;
case pq\Result::TUPLES_OK:
printf("-> fetching done\n");
break;
default:
printf("!! %s\n", $res->errorMessage);
break;
}
});
2013-02-22 12:14:00 +01:00
2013-02-14 14:54:22 +01:00
do {
while ($c->busy) {
2013-02-22 12:14:00 +01:00
$r = array($c->socket);
$w = $e = null;
if (stream_select($r, $w, $e, null)) {
$c->poll();
2013-02-14 14:54:22 +01:00
}
}
} while ($c->getResult());
2013-02-22 12:14:00 +01:00
2013-02-14 14:54:22 +01:00
?>
DONE
--EXPECTF--
Test
bool(false)
bool(true)
1
2
3
4
5
6
7
8
9
10
-> fetching done
DONE