Skip to content

Commit c5b4a50

Browse files
author
Yasuo Ohgaki
committed
Added test for pg_fetch_*() functions
1 parent b4c943e commit c5b4a50

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

ext/pgsql/tests/17result.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
PostgreSQL pg_fetch_*() functions
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
include("result.inc");
8+
?>
9+
--EXPECT--
10+
object(stdClass)(3) {
11+
["num"]=>
12+
string(1) "1"
13+
["str"]=>
14+
string(3) "ABC"
15+
["bin"]=>
16+
NULL
17+
}
18+
array(6) {
19+
[0]=>
20+
string(1) "1"
21+
["num"]=>
22+
string(1) "1"
23+
[1]=>
24+
string(3) "ABC"
25+
["str"]=>
26+
string(3) "ABC"
27+
[2]=>
28+
NULL
29+
["bin"]=>
30+
NULL
31+
}
32+
array(3) {
33+
[0]=>
34+
string(1) "1"
35+
[1]=>
36+
string(3) "ABC"
37+
[2]=>
38+
NULL
39+
}
40+
Ok

ext/pgsql/tests/result.inc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
error_reporting(E_ALL);
3+
4+
include 'config.inc';
5+
6+
$db = pg_connect($conn_str);
7+
8+
$sql = "SELECT * FROM $table_name";
9+
$result = pg_query($db, $sql) or die('Cannot qeury db');
10+
$rows = pg_num_rows($result);
11+
12+
$rec = pg_fetch_object($result, 1);
13+
var_dump($rec);
14+
$rec = pg_fetch_array($result, 1);
15+
var_dump($rec);
16+
$rec = pg_fetch_row($result, 1);
17+
var_dump($rec);
18+
19+
echo "Ok\n";
20+
21+
?>

0 commit comments

Comments
 (0)