xref: /PHP-7.4/ext/pgsql/tests/17result.phpt (revision 3f7210ef)
1--TEST--
2PostgreSQL pg_fetch_*() functions
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5--FILE--
6<?php
7error_reporting(E_ALL);
8
9include 'config.inc';
10
11$db = pg_connect($conn_str);
12
13$sql = "SELECT * FROM $table_name ORDER BY num";
14$result = pg_query($db, $sql) or die('Cannot query db');
15$rows = pg_num_rows($result);
16
17var_dump(pg_result_seek($result, 1));
18var_dump(pg_fetch_object($result));
19var_dump(pg_fetch_array($result, 1));
20var_dump(pg_fetch_row($result, 1));
21var_dump(pg_fetch_assoc($result, 1));
22var_dump(pg_result_seek($result, 0));
23
24echo "Ok\n";
25?>
26--EXPECT--
27bool(true)
28object(stdClass)#1 (3) {
29  ["num"]=>
30  string(1) "1"
31  ["str"]=>
32  string(3) "ABC"
33  ["bin"]=>
34  NULL
35}
36array(6) {
37  [0]=>
38  string(1) "1"
39  ["num"]=>
40  string(1) "1"
41  [1]=>
42  string(3) "ABC"
43  ["str"]=>
44  string(3) "ABC"
45  [2]=>
46  NULL
47  ["bin"]=>
48  NULL
49}
50array(3) {
51  [0]=>
52  string(1) "1"
53  [1]=>
54  string(3) "ABC"
55  [2]=>
56  NULL
57}
58array(3) {
59  ["num"]=>
60  string(1) "1"
61  ["str"]=>
62  string(3) "ABC"
63  ["bin"]=>
64  NULL
65}
66bool(true)
67Ok
68