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 34try { 35 pg_fetch_result($result, 0, -1); 36} catch (ValueError $e) { 37 echo $e->getMessage(), "\n"; 38} 39try { 40 pg_fetch_result($result, 0, 3); 41} catch (ValueError $e) { 42 echo $e->getMessage(), "\n"; 43} 44try { 45 pg_fetch_result($result, 0, "unknown"); 46} catch (ValueError $e) { 47 echo $e->getMessage(), "\n"; 48} 49try { 50 pg_fetch_all_columns($result, -1); 51} catch (ValueError $e) { 52 echo $e->getMessage(), "\n"; 53} 54try { 55 pg_fetch_all_columns($result, 3); 56} catch (ValueError $e) { 57 echo $e->getMessage(), "\n"; 58} 59 60pg_result_error($result); 61if (function_exists('pg_result_error_field')) { 62 pg_result_error_field($result, PGSQL_DIAG_SEVERITY); 63 pg_result_error_field($result, PGSQL_DIAG_SQLSTATE); 64 pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY); 65 pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL); 66 pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT); 67 pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION); 68 if (defined('PGSQL_DIAG_INTERNAL_POSITION')) 69 { 70 pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION); 71 } 72 if (defined('PGSQL_DIAG_INTERNAL_QUERY')) 73 { 74 pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY); 75 } 76 pg_result_error_field($result, PGSQL_DIAG_CONTEXT); 77 pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE); 78 pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE); 79 pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION); 80} 81pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";")); 82pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";")); 83pg_field_name($result, 0); 84pg_field_num($result, $field_name); 85pg_field_size($result, 0); 86pg_field_type($result, 0); 87pg_field_prtlen($result, 0); 88pg_field_is_null($result, 0); 89 90try { 91 pg_field_is_null($result, -1); 92} catch (ValueError $e) { 93 echo $e->getMessage(), "\n"; 94} 95try { 96 pg_field_is_null($result, 3); 97} catch (ValueError $e) { 98 echo $e->getMessage(), "\n"; 99} 100try { 101 pg_field_is_null($result, "unknown"); 102} catch (ValueError $e) { 103 echo $e->getMessage(), "\n"; 104} 105try { 106 pg_field_name($result, -1); 107} catch (ValueError $e) { 108 echo $e->getMessage(), "\n"; 109} 110try { 111 pg_field_name($result, 3); 112} catch (ValueError $e) { 113 echo $e->getMessage(), "\n"; 114} 115try { 116 pg_field_table($result, -1); 117} catch (ValueError $e) { 118 echo $e->getMessage(), "\n"; 119} 120try { 121 pg_field_table($result, 3); 122} catch (ValueError $e) { 123 echo $e->getMessage(), "\n"; 124} 125 126$result = pg_query($db, "INSERT INTO ".$table_name." VALUES (9999, 'ABC');"); 127pg_last_oid($result); 128var_dump(pg_fetch_all($result)); 129 130pg_free_result($result); 131pg_close($db); 132 133echo "OK"; 134?> 135--EXPECT-- 136Argument #3 must be greater than or equal to 0 137Argument #3 must be less than the number of fields for this result set 138Argument #3 must be a field name from this result set 139pg_fetch_all_columns(): Argument #2 ($field) must be greater than or equal to 0 140pg_fetch_all_columns(): Argument #2 ($field) must be less than the number of fields for this result set 141Argument #2 must be greater than or equal to 0 142Argument #2 must be less than the number of fields for this result set 143Argument #2 must be a field name from this result set 144pg_field_name(): Argument #2 ($field) must be greater than or equal to 0 145pg_field_name(): Argument #2 ($field) must be less than the number of fields for this result set 146pg_field_table(): Argument #2 ($field) must be greater than or equal to 0 147pg_field_table(): Argument #2 ($field) must be less than the number of fields for this result set 148array(0) { 149} 150OK 151