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