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

1.1     ! misho       1: --TEST--
        !             2: mysqli iterators
        !             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:        require('table.inc');
        !            17: 
        !            18:        echo "--- Testing default ---\n";
        !            19:        if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id")))
        !            20:                printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            21:        else {
        !            22:                foreach ($res as $row) {
        !            23:                        var_dump($row);
        !            24:                }
        !            25:                echo "======\n";
        !            26:                foreach ($res as $row) {
        !            27:                        var_dump($row);
        !            28:                }
        !            29:                mysqli_free_result($res);
        !            30:                foreach ($res as $row) {
        !            31:                        var_dump($row);
        !            32:                }
        !            33:        }
        !            34:        echo "--- Testing USE_RESULT ---\n";
        !            35:        if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT)))
        !            36:                printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            37:        else {
        !            38:                foreach ($res as $row) {
        !            39:                        var_dump($row);
        !            40:                }
        !            41:                echo "======\n";
        !            42:                foreach ($res as $row) {
        !            43:                        var_dump($row);
        !            44:                }
        !            45:                mysqli_free_result($res);
        !            46:        }
        !            47: 
        !            48:        echo "--- Testing STORE_RESULT ---\n";
        !            49:        if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT)))
        !            50:                printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            51:        else {
        !            52:                foreach ($res as $row) {
        !            53:                        var_dump($row);
        !            54:                }
        !            55:                echo "======\n";
        !            56:                foreach ($res as $row) {
        !            57:                        var_dump($row);
        !            58:                }
        !            59:                mysqli_free_result($res);
        !            60:        }
        !            61: 
        !            62:        mysqli_close($link);
        !            63: 
        !            64:        print "done!";
        !            65: ?>
        !            66: --CLEAN--
        !            67: <?php
        !            68:        require_once("clean_table.inc");
        !            69: ?>
        !            70: --EXPECTF--
        !            71: --- Testing default ---
        !            72: array(1) {
        !            73:   ["id"]=>
        !            74:   string(1) "1"
        !            75: }
        !            76: array(1) {
        !            77:   ["id"]=>
        !            78:   string(1) "2"
        !            79: }
        !            80: array(1) {
        !            81:   ["id"]=>
        !            82:   string(1) "3"
        !            83: }
        !            84: array(1) {
        !            85:   ["id"]=>
        !            86:   string(1) "4"
        !            87: }
        !            88: array(1) {
        !            89:   ["id"]=>
        !            90:   string(1) "5"
        !            91: }
        !            92: array(1) {
        !            93:   ["id"]=>
        !            94:   string(1) "6"
        !            95: }
        !            96: ======
        !            97: array(1) {
        !            98:   ["id"]=>
        !            99:   string(1) "1"
        !           100: }
        !           101: array(1) {
        !           102:   ["id"]=>
        !           103:   string(1) "2"
        !           104: }
        !           105: array(1) {
        !           106:   ["id"]=>
        !           107:   string(1) "3"
        !           108: }
        !           109: array(1) {
        !           110:   ["id"]=>
        !           111:   string(1) "4"
        !           112: }
        !           113: array(1) {
        !           114:   ["id"]=>
        !           115:   string(1) "5"
        !           116: }
        !           117: array(1) {
        !           118:   ["id"]=>
        !           119:   string(1) "6"
        !           120: }
        !           121: 
        !           122: Warning: main(): Couldn't fetch mysqli_result in %s on line %d
        !           123: --- Testing USE_RESULT ---
        !           124: array(1) {
        !           125:   ["id"]=>
        !           126:   string(1) "1"
        !           127: }
        !           128: array(1) {
        !           129:   ["id"]=>
        !           130:   string(1) "2"
        !           131: }
        !           132: array(1) {
        !           133:   ["id"]=>
        !           134:   string(1) "3"
        !           135: }
        !           136: array(1) {
        !           137:   ["id"]=>
        !           138:   string(1) "4"
        !           139: }
        !           140: array(1) {
        !           141:   ["id"]=>
        !           142:   string(1) "5"
        !           143: }
        !           144: array(1) {
        !           145:   ["id"]=>
        !           146:   string(1) "6"
        !           147: }
        !           148: ======
        !           149: 
        !           150: Warning: main(): Data fetched with MYSQLI_USE_RESULT can be iterated only once in %s on line %d
        !           151: --- Testing STORE_RESULT ---
        !           152: array(1) {
        !           153:   ["id"]=>
        !           154:   string(1) "1"
        !           155: }
        !           156: array(1) {
        !           157:   ["id"]=>
        !           158:   string(1) "2"
        !           159: }
        !           160: array(1) {
        !           161:   ["id"]=>
        !           162:   string(1) "3"
        !           163: }
        !           164: array(1) {
        !           165:   ["id"]=>
        !           166:   string(1) "4"
        !           167: }
        !           168: array(1) {
        !           169:   ["id"]=>
        !           170:   string(1) "5"
        !           171: }
        !           172: array(1) {
        !           173:   ["id"]=>
        !           174:   string(1) "6"
        !           175: }
        !           176: ======
        !           177: array(1) {
        !           178:   ["id"]=>
        !           179:   string(1) "1"
        !           180: }
        !           181: array(1) {
        !           182:   ["id"]=>
        !           183:   string(1) "2"
        !           184: }
        !           185: array(1) {
        !           186:   ["id"]=>
        !           187:   string(1) "3"
        !           188: }
        !           189: array(1) {
        !           190:   ["id"]=>
        !           191:   string(1) "4"
        !           192: }
        !           193: array(1) {
        !           194:   ["id"]=>
        !           195:   string(1) "5"
        !           196: }
        !           197: array(1) {
        !           198:   ["id"]=>
        !           199:   string(1) "6"
        !           200: }
        !           201: done!

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