1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-11-26 20:04:44 +01:00
ext-pq/tests/async009.phpt
Chris Wright 7b61b6b19f Add deallocate() and prepare() to Statement
Also adds async variants
2014-12-10 16:50:22 +00:00

54 lines
840 B
PHP

--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