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

1.1       misho       1: --TEST--
                      2: References to result sets - mysqlnd (no copies but references)
                      3: --SKIPIF--
                      4: <?php
                      5: require_once('skipif.inc');
                      6: require_once('skipifemb.inc');
                      7: require_once('skipifconnectfailure.inc');
                      8: 
                      9: require_once('connect.inc');
                     10: if (!$IS_MYSQLND)
                     11:        die("skip Test for mysqlnd only");
                     12: 
                     13: if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1))
                     14:        die("skip (TODO) PHP 6.0 has a difference debug_zval_dump output format");
                     15: ?>
                     16: <?php require_once('skipifemb.inc'); ?>
                     17: --FILE--
                     18: <?php
                     19:        require_once('connect.inc');
                     20:        require_once('table.inc');
                     21: 
                     22:        $references = array();
                     23: 
                     24:        if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) ||
                     25:                        !($res = mysqli_store_result($link)))
                     26:                printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     27: 
                     28:        $idx = 0;
                     29:        while ($row = mysqli_fetch_assoc($res)) {
                     30:                /* will overwrite itself */
                     31:                $references[$idx]['row_ref']            = &$row;
                     32:                $references[$idx]['row_copy']   = $row;
                     33:                $references[$idx]['id_ref']             = &$row['id'];
                     34:                $references[$idx++]['id_copy']  = $row['id'];
                     35:        }
                     36: 
                     37:        debug_zval_dump($references);
                     38:        mysqli_free_result($res);
                     39: 
                     40:        if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) ||
                     41:                        !($res = mysqli_use_result($link)))
                     42:                printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
                     43: 
                     44:        $rows = array();
                     45:        for ($i = 0; $i < 2; $i++) {
                     46:                $rows[$i] = mysqli_fetch_assoc($res);
                     47:                $references[$idx]['row_ref']            = &$rows[$i];
                     48:                $references[$idx]['row_copy']   = $rows[$i];
                     49:                $references[$idx]['id_ref']             = &$rows[$i]['id'];
                     50:                $references[$idx]['id_copy']            = $rows[$i]['id'];
                     51:                /* enforce seperation */
                     52:                $references[$idx]['id_copy_mod']= $rows[$i]['id'] + 0;
                     53:        }
                     54:        mysqli_free_result($res);
                     55: 
                     56:        debug_zval_dump($references);
                     57:        print "done!";
                     58: ?>
                     59: --EXPECTF--
                     60: array(1) refcount(2){
                     61:   [0]=>
                     62:   array(4) refcount(1){
                     63:     [%u|b%"row_ref"]=>
                     64:     &NULL refcount(2)
                     65:     [%u|b%"row_copy"]=>
                     66:     array(2) refcount(1){
                     67:       [%u|b%"id"]=>
                     68:       %unicode|string%(1) "1" refcount(2)
                     69:       [%u|b%"label"]=>
                     70:       %unicode|string%(1) "a" refcount(2)
                     71:     }
                     72:     [%u|b%"id_ref"]=>
                     73:     %unicode|string%(1) "1" refcount(1)
                     74:     [%u|b%"id_copy"]=>
                     75:     %unicode|string%(1) "1" refcount(1)
                     76:   }
                     77: }
                     78: array(2) refcount(2){
                     79:   [0]=>
                     80:   array(4) refcount(1){
                     81:     [%u|b%"row_ref"]=>
                     82:     &NULL refcount(2)
                     83:     [%u|b%"row_copy"]=>
                     84:     array(2) refcount(1){
                     85:       [%u|b%"id"]=>
                     86:       %unicode|string%(1) "1" refcount(1)
                     87:       [%u|b%"label"]=>
                     88:       %unicode|string%(1) "a" refcount(1)
                     89:     }
                     90:     [%u|b%"id_ref"]=>
                     91:     %unicode|string%(1) "1" refcount(1)
                     92:     [%u|b%"id_copy"]=>
                     93:     %unicode|string%(1) "1" refcount(1)
                     94:   }
                     95:   [1]=>
                     96:   array(5) refcount(1){
                     97:     [%u|b%"row_ref"]=>
                     98:     &array(2) refcount(2){
                     99:       [%u|b%"id"]=>
                    100:       &%unicode|string%(1) "2" refcount(2)
                    101:       [%u|b%"label"]=>
                    102:       %unicode|string%(1) "b" refcount(2)
                    103:     }
                    104:     [%u|b%"row_copy"]=>
                    105:     array(2) refcount(1){
                    106:       [%u|b%"id"]=>
                    107:       %unicode|string%(1) "2" refcount(1)
                    108:       [%u|b%"label"]=>
                    109:       %unicode|string%(1) "b" refcount(2)
                    110:     }
                    111:     [%u|b%"id_ref"]=>
                    112:     &%unicode|string%(1) "2" refcount(2)
                    113:     [%u|b%"id_copy"]=>
                    114:     %unicode|string%(1) "2" refcount(1)
                    115:     [%u|b%"id_copy_mod"]=>
                    116:     long(2) refcount(1)
                    117:   }
                    118: }
                    119: done!

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