Annotation of embedaddon/php/ext/pgsql/tests/26async_query_prepared.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: PostgreSQL async prepared queries
        !             3: --SKIPIF--
        !             4: <?php
        !             5: include("skipif.inc");
        !             6: if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() 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_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) {
        !            18:                echo "pg_send_prepare() 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:        pg_free_result($result);
        !            29: 
        !            30:        if (!pg_send_execute($db, 'php_test', array(100))) {
        !            31:                echo "pg_send_execute() error\n";
        !            32:        }
        !            33:        while(pg_connection_busy($db));  // busy wait: intended
        !            34:        if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
        !            35:                echo "pg_connection_status() error\n";
        !            36:        }
        !            37:        if (!($result = pg_get_result($db))) 
        !            38:        {
        !            39:                echo "pg_get_result() error\n";
        !            40:        }
        !            41: 
        !            42:        if (!($rows = pg_num_rows($result))) {
        !            43:                echo "pg_num_rows() error\n";
        !            44:        }
        !            45:        for ($i=0; $i < $rows; $i++) 
        !            46:        {
        !            47:                pg_fetch_array($result, $i, PGSQL_NUM);
        !            48:        }
        !            49:        for ($i=0; $i < $rows; $i++) 
        !            50:        {
        !            51:                pg_fetch_object($result);
        !            52:        }
        !            53:        for ($i=0; $i < $rows; $i++) 
        !            54:        {
        !            55:                pg_fetch_row($result, $i);
        !            56:        }
        !            57:        for ($i=0; $i < $rows; $i++) 
        !            58:        {
        !            59:                pg_fetch_result($result, $i, 0);
        !            60:        }
        !            61: 
        !            62:        pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
        !            63:        pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
        !            64:        pg_field_name($result, 0);
        !            65:        pg_field_num($result, $field_name);
        !            66:        pg_field_size($result, 0);
        !            67:        pg_field_type($result, 0);
        !            68:        pg_field_prtlen($result, 0);
        !            69:        pg_field_is_null($result, 0);
        !            70: 
        !            71:        if (!pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"))
        !            72:        {
        !            73:                echo "pg_send_prepare() error\n";
        !            74:        }
        !            75:        while(pg_connection_busy($db));  // busy wait: intended
        !            76:        if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
        !            77:                echo "pg_connection_status() error\n";
        !            78:        }
        !            79:        if (!($result = pg_get_result($db))) 
        !            80:        {
        !            81:                echo "pg_get_result() error\n";
        !            82:        }
        !            83:        pg_free_result($result);
        !            84: 
        !            85:        if (!pg_send_execute($db, "php_test2", array(9999, "A'BC")))
        !            86:        {
        !            87:                echo "pg_send_execute() error\n";
        !            88:        }
        !            89:        while(pg_connection_busy($db));  // busy wait: intended
        !            90:        if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
        !            91:                echo "pg_connection_status() error\n";
        !            92:        }
        !            93:        if (!($result = pg_get_result($db))) 
        !            94:        {
        !            95:                echo "pg_get_result() error\n";
        !            96:        }
        !            97: 
        !            98:        pg_last_oid($result);
        !            99:        pg_free_result($result);
        !           100: }
        !           101: pg_close($db);
        !           102: 
        !           103: echo "OK";
        !           104: ?>
        !           105: --EXPECT--
        !           106: OK

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