Annotation of embedaddon/php/ext/mysqli/tests/mysqli_stmt_fetch.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: mysqli_stmt_fetch()
                      3: --SKIPIF--
                      4: <?php
                      5: require_once('skipif.inc');
                      6: require_once('skipifemb.inc');
                      7: require_once('skipifconnectfailure.inc');
                      8: ?>
                      9: --FILE--
                     10: <?php
                     11:        /*
                     12:        NOTE: no datatype tests here! This is done by
                     13:        mysqli_stmt_bind_result.phpt already. Restrict
                     14:        this test case to the basics.
                     15:        */
                     16:        require_once("connect.inc");
                     17: 
                     18:        $tmp    = NULL;
                     19:        $link   = NULL;
                     20: 
                     21:        if (!is_null($tmp = @mysqli_stmt_fetch()))
                     22:                printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     23: 
                     24:        if (!is_null($tmp = @mysqli_stmt_fetch($link)))
                     25:                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     26: 
                     27:        require('table.inc');
                     28: 
                     29:        if (!$stmt = mysqli_stmt_init($link))
                     30:                printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     31: 
                     32:        // stmt object status test
                     33:        if (NULL !== ($tmp = mysqli_stmt_fetch($stmt)))
                     34:                printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     35: 
                     36:        if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
                     37:                printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
                     38: 
                     39:        // FIXME - different versions return different values ?!
                     40:        if ((NULL !== ($tmp = mysqli_stmt_fetch($stmt))) && (false !== $tmp))
                     41:                printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), $tmp);
                     42: 
                     43:        if (!mysqli_stmt_execute($stmt))
                     44:                printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
                     45: 
                     46:        if (true !== ($tmp = mysqli_stmt_fetch($stmt)))
                     47:                printf("[008] NULL, got %s/%s\n", gettype($tmp), $tmp);
                     48: 
                     49:        mysqli_stmt_close($stmt);
                     50:        if (!$stmt = mysqli_stmt_init($link))
                     51:                printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     52: 
                     53:        if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
                     54:                printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
                     55: 
                     56:        if (!mysqli_stmt_execute($stmt))
                     57:                printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
                     58: 
                     59:        $id = NULL;
                     60:        $label = NULL;
                     61:        if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label)))
                     62:                printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
                     63: 
                     64:        if (true !== ($tmp = mysqli_stmt_fetch($stmt)))
                     65:                printf("[013] Expecting boolean/true, got %s/%s, [%d] %s\n",
                     66:                        gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
                     67: 
                     68:        if (!mysqli_kill($link, mysqli_thread_id($link)))
                     69:                printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     70: 
                     71:        if (true !== ($tmp = mysqli_stmt_fetch($stmt)))
                     72:                printf("[015] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
                     73: 
                     74:        mysqli_stmt_close($stmt);
                     75: 
                     76:        if (NULL !== ($tmp = mysqli_stmt_fetch($stmt)))
                     77:                printf("[016] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     78: 
                     79:        mysqli_close($link);
                     80: 
                     81:        /* Check that the function alias exists. It's a deprecated function,
                     82:        but we have not announce the removal so far, therefore we need to check for it */
                     83:        if (!is_null($tmp = @mysqli_stmt_fetch()))
                     84:                printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     85: 
                     86:        print "done!";
                     87: ?>
                     88: --CLEAN--
                     89: <?php
                     90:        require_once("clean_table.inc");
                     91: ?>
                     92: --EXPECTF--
                     93: Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
                     94:  in %s on line %d
                     95: [014] [%d] Commands out of sync; you can't run this command now
                     96: 
                     97: Warning: mysqli_stmt_fetch(): Couldn't fetch mysqli_stmt in %s on line %d
                     98: done!

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