X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=tests%2Fasync008.phpt;fp=tests%2Fasync008.phpt;h=cebe9a35836504e980cc31151312ad27abd0c81e;hp=0000000000000000000000000000000000000000;hb=9255d2d54bca41644cf3588e4e4259a1855b58d7;hpb=316c62ff1038faa62e4ed5fc3c8c82347d277e4c diff --git a/tests/async008.phpt b/tests/async008.phpt new file mode 100644 index 0000000..cebe9a3 --- /dev/null +++ b/tests/async008.phpt @@ -0,0 +1,57 @@ +--TEST-- +async cursor +--SKIPIF-- + +--FILE-- +busy) { + $r = array($c->socket); + $w = $e = null; + if (stream_select($r, $w, $e, null)) { + $c->poll(); + } + } + } while ($c->getResult()); +} + +$c = new pq\Connection(PQ_DSN); +$p = $c->declareAsync("mycursor", pq\Cursor::WITH_HOLD, + "SELECT * FROM generate_series(0,29) s WHERE (s%2)=0"); +complete($c); + +do { + $p->fetchAsync(2, function ($r) { + foreach ($r as $row) { + foreach ($row as $col) { + echo " $col"; + } + echo "\n"; + } + }); + complete($p->connection); + $p->moveAsync(1, function ($r) use(&$keep_going) { + $keep_going = $r->affectedRows; + }); + complete($p->connection); +} while ($keep_going); + +?> +===DONE=== +--EXPECT-- +Test + 0 + 2 + 6 + 8 + 12 + 14 + 18 + 20 + 24 + 26 +===DONE===