1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-12-11 08:59:45 +01:00
ext-pq/tests/cursor001.phpt

63 lines
966 B
Plaintext
Raw Normal View History

2014-04-04 15:48:20 +02:00
--TEST--
cursor
--SKIPIF--
<?php include "_skipif.inc"; ?>
--FILE--
<?php
echo "Test\n";
include "_setup.inc";
$c = new pq\Connection(PQ_DSN);
$p = $c->declare("mycursor", pq\Cursor::WITH_HOLD,
"SELECT * FROM generate_series(0,29) s WHERE (s%2)=0");
for ($r = $p->fetch(2); $r->numRows; $p->move(1), $r = $p->fetch(2)) {
foreach ($r as $row) {
foreach ($row as $col) {
echo " $col";
}
echo "\n";
}
}
2014-10-06 12:13:04 +02:00
try {
$p = new pq\Cursor($c, "mycursor", pq\Cursor::WITH_HOLD,
"SELECT * FROM generate_series(0,29) s WHERE (s%2)=0");
} catch (Exception $ex) {
$p->close();
}
$p = new pq\Cursor($c, "mycursor", pq\Cursor::WITH_HOLD,
"SELECT * FROM generate_series(0,29) s WHERE (s%2)=0");
for ($r = $p->fetch(2); $r->numRows; $p->move(1), $r = $p->fetch(2)) {
foreach ($r as $row) {
foreach ($row as $col) {
echo " $col";
}
echo "\n";
}
}
2014-04-04 15:48:20 +02:00
?>
===DONE===
--EXPECT--
Test
0
2
6
8
12
14
18
20
24
26
2014-10-06 12:13:04 +02:00
0
2
6
8
12
14
18
20
24
26
2014-04-04 15:48:20 +02:00
===DONE===