0382ade3db069402ba4eb93da16f63add4898c71
[m6w6/ext-pq] / tests / async005.phpt
1 --TEST--
2 async prepared statement
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 function complete($s) {
12 do {
13 while ($s->connection->busy) {
14 $r = array($s->connection->socket);
15 $w = $e = null;
16 if (stream_select($r, $w, $e, null)) {
17 $s->connection->poll();
18 }
19 }
20 } while ($s->connection->getResult());
21 }
22
23 $c = new pq\Connection(PQ_DSN);
24 $s = $c->prepareAsync("test", "SELECT \$1,\$2::int4", array($c->types->byName->int4->oid));
25
26 complete($s);
27
28 $s->execAsync(array(1,2), function ($res) {
29 var_dump($res);
30 });
31
32 complete($s);
33
34 ?>
35 DONE
36 --EXPECTF--
37 Test
38 object(pq\Result)#%d (6) {
39 ["status"]=>
40 int(2)
41 ["errorMessage"]=>
42 string(0) ""
43 ["numRows"]=>
44 int(1)
45 ["numCols"]=>
46 int(2)
47 ["affectedRows"]=>
48 int(1)
49 ["fetchType"]=>
50 int(0)
51 }
52 DONE