1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-12-02 17:28:35 +01:00
ext-pq/tests/unbuffered001.phpt
Michael Wallner 3024b0b5a9 tests & fixes
2013-02-14 14:54:22 +01:00

63 lines
981 B
PHP

--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:
printf("%s\n", $res->fetchCol());
break;
case pq\Result::TUPLES_OK:
printf("-> fetching done\n");
break;
default:
printf("!! %s\n", $res->errorMessage);
break;
}
});
do {
while ($c->busy) {
switch ($c->poll()) {
case pq\Connection::POLLING_READING:
$w=$e=array();
$r=array($c->socket);
stream:select($r,$w,$e,1);
break;
case pq\Connection::POLLING_WRITING:
$r=$e=array();
$w=array($c->socket);
stream_select($r,$w,$e,1);
break;
}
}
} while ($c->getResult());
?>
DONE
--EXPECTF--
Test
bool(false)
bool(true)
1
2
3
4
5
6
7
8
9
10
-> fetching done
DONE