@@ -12,48 +12,51 @@ include('config.inc');
12
12
13
13
$ db = pg_connect ($ conn_str );
14
14
15
- $ result = pg_prepare ($ db , "php_test " , "SELECT * FROM " .$ table_name ." WHERE num > \$1; " );
16
- pg_result_error ($ result );
17
- pg_free_result ($ result );
18
- $ result = pg_execute ($ db , "php_test " , array (100 ));
19
- if (!($ rows = pg_num_rows ($ result )))
20
- {
21
- echo "pg_num_row() error \n" ;
22
- }
23
- for ($ i =0 ; $ i < $ rows ; $ i ++)
24
- {
25
- pg_fetch_array ($ result , $ i , PGSQL_NUM );
26
- }
27
- for ($ i =0 ; $ i < $ rows ; $ i ++)
28
- {
29
- pg_fetch_object ($ result );
30
- }
31
- for ($ i =0 ; $ i < $ rows ; $ i ++)
32
- {
33
- pg_fetch_row ($ result , $ i );
34
- }
35
- for ($ i =0 ; $ i < $ rows ; $ i ++)
36
- {
37
- pg_fetch_result ($ result , $ i , 0 );
38
- }
15
+ $ version = pg_version ($ db );
16
+ if ($ version ['protocol ' ] >= 3 ) {
17
+ $ result = pg_prepare ($ db , "php_test " , "SELECT * FROM " .$ table_name ." WHERE num > \$1; " );
18
+ pg_result_error ($ result );
19
+ pg_free_result ($ result );
20
+ $ result = pg_execute ($ db , "php_test " , array (100 ));
21
+ if (!($ rows = pg_num_rows ($ result )))
22
+ {
23
+ echo "pg_num_row() error \n" ;
24
+ }
25
+ for ($ i =0 ; $ i < $ rows ; $ i ++)
26
+ {
27
+ pg_fetch_array ($ result , $ i , PGSQL_NUM );
28
+ }
29
+ for ($ i =0 ; $ i < $ rows ; $ i ++)
30
+ {
31
+ pg_fetch_object ($ result );
32
+ }
33
+ for ($ i =0 ; $ i < $ rows ; $ i ++)
34
+ {
35
+ pg_fetch_row ($ result , $ i );
36
+ }
37
+ for ($ i =0 ; $ i < $ rows ; $ i ++)
38
+ {
39
+ pg_fetch_result ($ result , $ i , 0 );
40
+ }
39
41
40
- pg_result_error ($ result );
41
- pg_num_rows (pg_execute ($ db , "php_test " , array (100 )));
42
- pg_num_fields (pg_execute ($ db , "php_test " , array (100 )));
43
- pg_field_name ($ result , 0 );
44
- pg_field_num ($ result , $ field_name );
45
- pg_field_size ($ result , 0 );
46
- pg_field_type ($ result , 0 );
47
- pg_field_prtlen ($ result , 0 );
48
- pg_field_is_null ($ result , 0 );
42
+ pg_result_error ($ result );
43
+ pg_num_rows (pg_execute ($ db , "php_test " , array (100 )));
44
+ pg_num_fields (pg_execute ($ db , "php_test " , array (100 )));
45
+ pg_field_name ($ result , 0 );
46
+ pg_field_num ($ result , $ field_name );
47
+ pg_field_size ($ result , 0 );
48
+ pg_field_type ($ result , 0 );
49
+ pg_field_prtlen ($ result , 0 );
50
+ pg_field_is_null ($ result , 0 );
49
51
50
- $ result = pg_prepare ($ db , "php_test2 " , "INSERT INTO " .$ table_name ." VALUES ( \$1, \$2); " );
51
- pg_result_error ($ result );
52
- pg_free_result ($ result );
53
- $ result = pg_execute ($ db , "php_test2 " , array (9999 , "A'BC " ));
54
- pg_last_oid ($ result );
52
+ $ result = pg_prepare ($ db , "php_test2 " , "INSERT INTO " .$ table_name ." VALUES ( \$1, \$2); " );
53
+ pg_result_error ($ result );
54
+ pg_free_result ($ result );
55
+ $ result = pg_execute ($ db , "php_test2 " , array (9999 , "A'BC " ));
56
+ pg_last_oid ($ result );
55
57
56
- pg_free_result ($ result );
58
+ pg_free_result ($ result );
59
+ }
57
60
pg_close ($ db );
58
61
59
62
echo "OK " ;
0 commit comments