prepare v2.2.3
[m6w6/ext-pq] / tests / async009.phpt
1 --TEST--
2 Deallocate and prepare statement async
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8 include "_setup.inc";
9
10 function complete($c) {
11 do {
12 while ($c->busy) {
13 $r = array($c->socket);
14 $w = $e = null;
15 if (stream_select($r, $w, $e, null)) {
16 $c->poll();
17 }
18 }
19 } while ($c->getResult());
20 }
21
22 $c = new pq\Connection(PQ_DSN);
23 $s = $c->prepareAsync("test1", "SELECT 'test' || \$1");
24 complete($c);
25
26 $r = $s->exec(array("ing"));
27 $r->fetchCol($d);
28 var_dump($d);
29
30 $s->deallocateAsync();
31 complete($c);
32
33 try {
34 $s->exec(array("ing"));
35 } catch (pq\Exception\BadMethodCallException $e) {
36 echo "Caught exception\n";
37 }
38
39 $s->prepareAsync();
40 complete($c);
41
42 $r = $s->exec(array("ing"));
43 $r->fetchCol($d);
44 var_dump($d);
45
46 ?>
47 DONE
48 --EXPECT--
49 Test
50 string(7) "testing"
51 Caught exception
52 string(7) "testing"
53 DONE