Annotation of embedaddon/php/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_next_result.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: mysqli_stmt_execute() - SP, next result
        !             3: --SKIPIF--
        !             4: <?php
        !             5: require_once('skipif.inc');
        !             6: require_once('skipifconnectfailure.inc');
        !             7: require_once('connect.inc');
        !             8: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        !             9:        die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
        !            10: }
        !            11: if (mysqli_get_server_version($link) < 50503) {
        !            12:        die(sprintf('skip Needs MySQL 5.5.3+, found version %d.', mysqli_get_server_version($link)));
        !            13: }
        !            14: ?>
        !            15: --FILE--
        !            16: <?php
        !            17:        require_once('connect.inc');
        !            18: 
        !            19:        if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
        !            20:                printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
        !            21:                  $host, $user, $db, $port, $socket);
        !            22:        }
        !            23: 
        !            24:        if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'))
        !            25:                printf("[003] [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
        !            26: 
        !            27:        if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25)) BEGIN SELECT ver_in AS _ver_out; END;')) {
        !            28:                // one result set
        !            29:                if (!$stmt = mysqli_prepare($link, 'CALL p(?)'))
        !            30:                        printf("[005] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            31: 
        !            32:                $version = 'myversion';
        !            33:                if (!mysqli_stmt_bind_param($stmt, 's', $version))
        !            34:                        printf("[006] Cannot bind input parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            35: 
        !            36:                if (!mysqli_stmt_execute($stmt))
        !            37:                        printf("[007] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            38: 
        !            39:                $version = 'unknown';
        !            40:                if (!mysqli_stmt_bind_result($stmt, $version) ||
        !            41:                                !mysqli_stmt_fetch($stmt))
        !            42:                        printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            43: 
        !            44:                if ($version !== "myversion")
        !            45:                        printf("[009] Results seem wrong, got %s, [%d] %s\n",
        !            46:                                $version,
        !            47:                                mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            48: 
        !            49:                mysqli_stmt_free_result($stmt);
        !            50: 
        !            51:                printf("[010] More results: %s\n", (mysqli_more_results($link)) ? "yes" : "no");
        !            52:                printf("[011] Next result: %s\n", (mysqli_next_result($link)) ? "yes" : "no");
        !            53: 
        !            54:                if (!mysqli_stmt_close($stmt))
        !            55:                        printf("[012] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            56: 
        !            57:                if (!$link->query("SELECT 1"))
        !            58:                        printf("[013] [%d] %s\n", $link->errno, $link->error);
        !            59: 
        !            60:        } else {
        !            61:                printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
        !            62:        }
        !            63: 
        !            64:        if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'))
        !            65:                printf("[014] [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
        !            66: 
        !            67:        if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25)) BEGIN SELECT ver_in AS _ver_out; SELECT 1 AS _more; END;')) {
        !            68:                // two result sets
        !            69:                if (!$stmt = mysqli_prepare($link, 'CALL p(?)'))
        !            70:                        printf("[015] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            71: 
        !            72:                $version = 'myversion';
        !            73:                if (!mysqli_stmt_bind_param($stmt, 's', $version))
        !            74:                        printf("[016] Cannot bind input parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            75: 
        !            76:                if (!mysqli_stmt_execute($stmt))
        !            77:                        printf("[017] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            78: 
        !            79:                $version = NULL;
        !            80:                if (!mysqli_stmt_bind_result($stmt, $version) ||
        !            81:                                !mysqli_stmt_fetch($stmt))
        !            82:                        printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            83: 
        !            84:                if ($version !== "myversion")
        !            85:                        printf("[019] Results seem wrong, got %s, [%d] %s\n",
        !            86:                                $version,
        !            87:                                mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            88: 
        !            89:                if (!mysqli_more_results($link) || !mysqli_next_result($link))
        !            90:                        printf("[020] [%d] %s\n", $link->errno, $link->error);
        !            91: 
        !            92:                $more = NULL;
        !            93:                if (!mysqli_stmt_bind_result($stmt, $more) ||
        !            94:                                !mysqli_stmt_fetch($stmt))
        !            95:                        printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !            96: 
        !            97:                if ($more !== 1)
        !            98:                        printf("[022] Results seem wrong, got %s, [%d] %s\n",
        !            99:                                $more,
        !           100:                                mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !           101: 
        !           102:                if (!mysqli_stmt_close($stmt))
        !           103:                        printf("[023] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
        !           104: 
        !           105: 
        !           106:                if (!$link->query("SELECT 1"))
        !           107:                        printf("[024] [%d] %s\n", $link->errno, $link->error);
        !           108: 
        !           109:        } else {
        !           110:                printf("[025] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
        !           111:        }
        !           112: 
        !           113:        mysqli_close($link);
        !           114:        print "done!";
        !           115: ?>
        !           116: --CLEAN--
        !           117: <?php
        !           118: require_once("connect.inc");
        !           119: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
        !           120:    printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
        !           121: 
        !           122: @mysqli_query($link, 'DROP PROCEDURE IF EXISTS p');
        !           123: 
        !           124: mysqli_close($link);
        !           125: ?>
        !           126: --XFAIL--
        !           127: Unsupported and undefined, under development
        !           128: --EXPECTF--
        !           129: [010] More results: yes
        !           130: [011] Next result: yes
        !           131: done!

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