xref: /PHP-7.1/ext/pgsql/tests/03sync_query.phpt (revision 7af945e2)
1--TEST--
2PostgreSQL sync query
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5--FILE--
6<?php
7
8include('config.inc');
9
10$db = pg_connect($conn_str);
11
12$result = pg_query($db, "SELECT * FROM ".$table_name.";");
13if (!($rows   = pg_num_rows($result)))
14{
15	echo "pg_num_row() error\n";
16}
17for ($i=0; $i < $rows; $i++)
18{
19	pg_fetch_array($result, $i, PGSQL_NUM);
20}
21for ($i=0; $i < $rows; $i++)
22{
23	pg_fetch_object($result);
24}
25for ($i=0; $i < $rows; $i++)
26{
27	pg_fetch_row($result, $i);
28}
29for ($i=0; $i < $rows; $i++)
30{
31	pg_fetch_result($result, $i, 0);
32}
33
34pg_result_error($result);
35if (function_exists('pg_result_error_field')) {
36	pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
37	pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
38	pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
39	pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
40	pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
41	pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
42	if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
43	{
44		pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
45	}
46	if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
47	{
48		pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
49	}
50	pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
51	pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
52	pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
53	pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);
54}
55pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
56pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
57pg_field_name($result, 0);
58pg_field_num($result, $field_name);
59pg_field_size($result, 0);
60pg_field_type($result, 0);
61pg_field_prtlen($result, 0);
62pg_field_is_null($result, 0);
63
64$result = pg_query($db, "INSERT INTO ".$table_name." VALUES (9999, 'ABC');");
65pg_last_oid($result);
66
67pg_free_result($result);
68pg_close($db);
69
70echo "OK";
71?>
72--EXPECT--
73OK
74