1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-12-02 17:28:35 +01:00
ext-pq/tests/basic001.phpt
Michael Wallner f7aeb22e11 tests
2013-01-21 12:13:04 +01:00

52 lines
1001 B
PHP

--TEST--
basic functionality
--SKIPIF--
<?php include "_skipif.inc"; ?>
--FILE--
<?php
echo "Test\n";
include "_setup.inc";
$con = new pq\Connection(PQ_DSN);
$res = $con->exec("SELECT 1 as one, 2 as two from generate_series(1,2)");
var_dump($res->status == pq\Result::TUPLES_OK);
var_dump($res->numRows);
var_dump($res->numCols);
foreach ($res as $rowNum => $rowData) {
printf("%d.0 => %d\n", $rowNum, $rowData[0]);
printf("%d.1 => %d\n", $rowNum, $rowData[1]);
}
$res->fetchType = pq\Result::FETCH_ASSOC;
foreach ($res as $rowNum => $rowData) {
printf("%d.0 => %d\n", $rowNum, $rowData["one"]);
printf("%d.1 => %d\n", $rowNum, $rowData["two"]);
}
$res->fetchType = pq\Result::FETCH_OBJECT;
foreach ($res as $rowNum => $rowData) {
printf("%d.0 => %d\n", $rowNum, $rowData->one);
printf("%d.1 => %d\n", $rowNum, $rowData->two);
}
?>
DONE
--EXPECT--
Test
bool(true)
int(2)
int(2)
0.0 => 1
0.1 => 2
1.0 => 1
1.1 => 2
0.0 => 1
0.1 => 2
1.0 => 1
1.1 => 2
0.0 => 1
0.1 => 2
1.0 => 1
1.1 => 2
DONE