release 2.1.6
[m6w6/ext-pq] / tests / flush001.phpt
1 --TEST--
2 flush
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 $c = new pq\Connection(PQ_DSN);
12 $c->nonblocking = true;
13 var_dump($c->nonblocking);
14 $c->execAsync("SELECT '".str_repeat("a", 6e7)."'", function($r) {
15 $r->fetchCol($s);
16 var_dump(strlen($s));
17 });
18 var_dump($flushed = $c->flush());
19 do {
20 while (!$flushed || $c->busy) {
21 $r = $c->busy ? [$c->socket] : null;
22 $w = !$flushed ?[$c->socket] : null;
23
24 if (stream_select($r, $w, $e, null)) {
25 if ($r) {
26 printf("P%d", $c->poll());
27 }
28 if ($w) {
29 printf("F%d", $flushed = $c->flush());
30 }
31 }
32 }
33 echo "\n";
34 } while ($c->getResult());
35 ?>
36 ===DONE===
37 --EXPECTF--
38 Test
39 bool(true)
40 bool(%s)
41 %r(F0)*(F1)*(P3)+%r
42 int(60000000)
43
44 ===DONE===