1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-11-30 04:19:49 +01:00
ext-pq/tests/basic001.phpt
Michael Wallner 3024b0b5a9 tests & fixes
2013-02-14 14:54:22 +01:00

55 lines
1.1 KiB
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);
var_dump(count($res) == $res->count(), $res->numRows == count($res));
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)
bool(true)
bool(true)
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