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

1.1       misho       1: --TEST--
                      2: mysqli_fetch_assoc()
                      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:        require_once("connect.inc");
                     12: 
                     13:        $tmp    = NULL;
                     14:        $link   = NULL;
                     15: 
                     16:        // Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
                     17: 
                     18:        if (!is_null($tmp = @mysqli_fetch_assoc()))
                     19:                printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     20: 
                     21:        if (!is_null($tmp = @mysqli_fetch_assoc($link)))
                     22:                printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     23: 
                     24:        require('table.inc');
                     25:        if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) {
                     26:                printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     27:        }
                     28: 
                     29:        print "[005]\n";
                     30:        var_dump(mysqli_fetch_assoc($res));
                     31: 
                     32:        print "[006]\n";
                     33:        var_dump(mysqli_fetch_assoc($res));
                     34: 
                     35:        mysqli_free_result($res);
                     36: 
                     37:        if (!$res = mysqli_query($link, "SELECT
                     38:                1 AS a,
                     39:                2 AS a,
                     40:                3 AS c,
                     41:                4 AS C,
                     42:                NULL AS d,
                     43:                true AS e,
                     44:                5 AS '-1',
                     45:                6 AS '-10',
                     46:                7 AS '-100',
                     47:                8 AS '-1000',
                     48:                9 AS '10000',
                     49:                'a' AS '100000',
                     50:                'b' AS '1000000',
                     51:                'c' AS '9',
                     52:                'd' AS '9',
                     53:                'e' AS '01',
                     54:                'f' AS '-02'
                     55:        ")) {
                     56:                printf("[007] Cannot run query, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     57:        }
                     58:        print "[008]\n";
                     59:        var_dump(mysqli_fetch_assoc($res));
                     60: 
                     61:        mysqli_free_result($res);
                     62: 
                     63:        if (NULL !== ($tmp = mysqli_fetch_assoc($res)))
                     64:                printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     65: 
                     66:        mysqli_close($link);
                     67: 
                     68:        print "done!";
                     69: ?>
                     70: --CLEAN--
                     71: <?php
                     72:        require_once("clean_table.inc");
                     73: ?>
                     74: --EXPECTF--
                     75: [005]
                     76: array(2) {
                     77:   [%u|b%"id"]=>
                     78:   %unicode|string%(1) "1"
                     79:   [%u|b%"label"]=>
                     80:   %unicode|string%(1) "a"
                     81: }
                     82: [006]
                     83: NULL
                     84: [008]
                     85: array(15) {
                     86:   [%u|b%"a"]=>
                     87:   %unicode|string%(1) "2"
                     88:   [%u|b%"c"]=>
                     89:   %unicode|string%(1) "3"
                     90:   [%u|b%"C"]=>
                     91:   %unicode|string%(1) "4"
                     92:   [%u|b%"d"]=>
                     93:   NULL
                     94:   [%u|b%"e"]=>
                     95:   %unicode|string%(1) "1"
                     96:   [-1]=>
                     97:   %unicode|string%(1) "5"
                     98:   [-10]=>
                     99:   %unicode|string%(1) "6"
                    100:   [-100]=>
                    101:   %unicode|string%(1) "7"
                    102:   [-1000]=>
                    103:   %unicode|string%(1) "8"
                    104:   [10000]=>
                    105:   %unicode|string%(1) "9"
                    106:   [100000]=>
                    107:   %unicode|string%(1) "a"
                    108:   [1000000]=>
                    109:   %unicode|string%(1) "b"
                    110:   [9]=>
                    111:   %unicode|string%(1) "d"
                    112:   [%u|b%"01"]=>
                    113:   %unicode|string%(1) "e"
                    114:   [%u|b%"-02"]=>
                    115:   %unicode|string%(1) "f"
                    116: }
                    117: 
                    118: Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d
                    119: done!

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