File: async009.phpt

package info (click to toggle)
php-pq 2.2.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 788 kB
  • sloc: ansic: 8,210; xml: 175; sh: 102; awk: 40; pascal: 9; makefile: 1
file content (53 lines) | stat: -rw-r--r-- 840 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--TEST--
Deallocate and prepare statement async
--SKIPIF--
<?php include "_skipif.inc"; ?>
--FILE--
<?php
echo "Test\n";
include "_setup.inc";

function complete($c) {
	do {
		while ($c->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);
$s = $c->prepareAsync("test1", "SELECT 'test' || \$1");
complete($c);

$r = $s->exec(array("ing"));
$r->fetchCol($d);
var_dump($d);

$s->deallocateAsync();
complete($c);

try {
  $s->exec(array("ing"));
} catch (pq\Exception\BadMethodCallException $e) {
  echo "Caught exception\n";
}

$s->prepareAsync();
complete($c);

$r = $s->exec(array("ing"));
$r->fetchCol($d);
var_dump($d);

?>
DONE
--EXPECT--
Test
string(7) "testing"
Caught exception
string(7) "testing"
DONE