Annotation of embedaddon/php/ext/mysql/tests/mysql_result.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: mysql_result()
        !             3: --SKIPIF--
        !             4: <?php
        !             5: require_once('skipif.inc');
        !             6: require_once('skipifconnectfailure.inc');
        !             7: ?>
        !             8: --FILE--
        !             9: <?php
        !            10: require_once("connect.inc");
        !            11: 
        !            12: $tmp    = NULL;
        !            13: $link   = NULL;
        !            14: 
        !            15: // string mysql_result ( resource result, int row [, mixed field] )
        !            16: 
        !            17: if (!is_null($tmp = @mysql_result()))
        !            18:        printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
        !            19: 
        !            20: if (!is_null($tmp = @mysql_result($link)))
        !            21:        printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
        !            22: 
        !            23: require_once('table.inc');
        !            24: if (!$res = mysql_query("SELECT id, label, id AS _id, CONCAT(label, 'a') _label, NULL as _foo FROM test _test ORDER BY id ASC LIMIT 1", $link)) {
        !            25:        printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
        !            26: }
        !            27: 
        !            28: var_dump(mysql_result($res, -1));
        !            29: var_dump(mysql_result($res, 2));
        !            30: 
        !            31: var_dump(mysql_result($res, 0, -1));
        !            32: var_dump(mysql_result($res, 0, 500));
        !            33: 
        !            34: print "valid fields\n";
        !            35: var_dump(mysql_result($res, 0));
        !            36: var_dump(mysql_result($res, 0, 1));
        !            37: 
        !            38: var_dump(mysql_result($res, 0, 'id'));
        !            39: var_dump(mysql_result($res, 0, '_test.id'));
        !            40: var_dump(mysql_result($res, 0, 'label'));
        !            41: var_dump(mysql_result($res, 0, '_test.label'));
        !            42: print "some invalid fields\n";
        !            43: var_dump(mysql_result($res, 0, 'unknown'));
        !            44: var_dump(mysql_result($res, 0, '_test.'));
        !            45: var_dump(mysql_result($res, 0, chr(0)));
        !            46: var_dump(mysql_result($res, 0, '_test.' . chr(0)));
        !            47: print "_id\n";
        !            48: var_dump(mysql_result($res, 0, '_id'));
        !            49: print "_label\n";
        !            50: var_dump(mysql_result($res, 0, '_label'));
        !            51: print "_foo\n";
        !            52: var_dump(mysql_result($res, 0, '_foo'));
        !            53: var_dump(mysql_result($res, 0, 'test.id'));
        !            54: var_dump(mysql_result($res, 0, 'test.label'));
        !            55: 
        !            56: mysql_free_result($res);
        !            57: 
        !            58: var_dump(mysql_result($res, 0));
        !            59: 
        !            60: mysql_close($link);
        !            61: print "done!";
        !            62: ?>
        !            63: --CLEAN--
        !            64: <?php
        !            65: require_once("clean_table.inc");
        !            66: ?>
        !            67: --EXPECTF--
        !            68: Warning: mysql_result(): Unable to jump to row -1 on MySQL result index %d in %s on line %d
        !            69: bool(false)
        !            70: 
        !            71: Warning: mysql_result(): Unable to jump to row 2 on MySQL result index %d in %s on line %d
        !            72: bool(false)
        !            73: 
        !            74: Warning: mysql_result(): Bad column offset specified in %s on line %d
        !            75: bool(false)
        !            76: 
        !            77: Warning: mysql_result(): Bad column offset specified in %s on line %d
        !            78: bool(false)
        !            79: valid fields
        !            80: %unicode|string%(1) "1"
        !            81: %unicode|string%(1) "a"
        !            82: %unicode|string%(1) "1"
        !            83: %unicode|string%(1) "1"
        !            84: %unicode|string%(1) "a"
        !            85: %unicode|string%(1) "a"
        !            86: some invalid fields
        !            87: 
        !            88: Warning: mysql_result(): unknown not found in MySQL result index %d in %s on line %d
        !            89: bool(false)
        !            90: 
        !            91: Warning: mysql_result(): _test. not found in MySQL result index %d in %s on line %d
        !            92: bool(false)
        !            93: 
        !            94: Warning: mysql_result():  not found in MySQL result index %d in %s on line %d
        !            95: bool(false)
        !            96: 
        !            97: Warning: mysql_result(): _test. not found in MySQL result index %d in %s on line %d
        !            98: bool(false)
        !            99: _id
        !           100: %unicode|string%(1) "1"
        !           101: _label
        !           102: string(2) "aa"
        !           103: _foo
        !           104: NULL
        !           105: 
        !           106: Warning: mysql_result(): test.id not found in MySQL result index %d in %s on line %d
        !           107: bool(false)
        !           108: 
        !           109: Warning: mysql_result(): test.label not found in MySQL result index %d in %s on line %d
        !           110: bool(false)
        !           111: 
        !           112: Warning: mysql_result(): %d is not a valid MySQL result resource in %s on line %d
        !           113: bool(false)
        !           114: done!

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