mirror of
https://github.com/danog/ext-pq.git
synced 2024-11-30 04:19:49 +01:00
7b61b6b19f
Also adds async variants
54 lines
840 B
PHP
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
|