Annotation of embedaddon/php/ext/pgsql/tests/25async_query_params.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: PostgreSQL async query params
                      3: --SKIPIF--
                      4: <?php
                      5: include("skipif.inc");
                      6: if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: 
                     11: include('config.inc');
                     12: 
                     13: $db = pg_connect($conn_str);
                     14: 
                     15: $version = pg_version($db);
                     16: if ($version['protocol'] >= 3) {
                     17:        if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) {
                     18:                echo "pg_send_query_params() error\n";
                     19:        }
                     20:        while(pg_connection_busy($db));  // busy wait: intended
                     21:        if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
                     22:                echo "pg_connection_status() error\n";
                     23:        }
                     24:        if (!($result = pg_get_result($db))) 
                     25:        {
                     26:                echo "pg_get_result() error\n";
                     27:        }
                     28:        if (!($rows = pg_num_rows($result))) {
                     29:                echo "pg_num_rows() error\n";
                     30:        }
                     31:        for ($i=0; $i < $rows; $i++) 
                     32:        {
                     33:                pg_fetch_array($result, $i, PGSQL_NUM);
                     34:        }
                     35:        for ($i=0; $i < $rows; $i++) 
                     36:        {
                     37:                pg_fetch_object($result);
                     38:        }
                     39:        for ($i=0; $i < $rows; $i++) 
                     40:        {
                     41:                pg_fetch_row($result, $i);
                     42:        }
                     43:        for ($i=0; $i < $rows; $i++) 
                     44:        {
                     45:                pg_fetch_result($result, $i, 0);
                     46:        }
                     47: 
                     48:        pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
                     49:        pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
                     50:        pg_field_name($result, 0);
                     51:        pg_field_num($result, $field_name);
                     52:        pg_field_size($result, 0);
                     53:        pg_field_type($result, 0);
                     54:        pg_field_prtlen($result, 0);
                     55:        pg_field_is_null($result, 0);
                     56: 
                     57:        if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")))
                     58:        {
                     59:                echo "pg_send_query_params() error\n";
                     60:        }
                     61: 
                     62:        pg_last_oid($result);
                     63:        pg_free_result($result);
                     64: }
                     65: pg_close($db);
                     66: 
                     67: echo "OK";
                     68: ?>
                     69: --EXPECT--
                     70: OK

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>