Annotation of embedaddon/php/ext/mysql/tests/mysql_fetch_object.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: mysql_fetch_object()
                      3: --SKIPIF--
                      4: <?php
                      5: require_once('skipif.inc');
                      6: require_once('skipifconnectfailure.inc');
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: include "connect.inc";
                     11: 
                     12: $tmp    = NULL;
                     13: $link   = NULL;
                     14: 
                     15: if (!is_null($tmp = @mysql_fetch_object()))
                     16:        printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
                     17: 
                     18: if (false !== ($tmp = @mysql_fetch_object($link)))
                     19:        printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
                     20: 
                     21: require('table.inc');
                     22: if (!$res = mysql_query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5", $link)) {
                     23:        printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
                     24: }
                     25: 
                     26: var_dump(mysql_fetch_object($res));
                     27: 
                     28: class mysql_fetch_object_test {
                     29: 
                     30:        public $a = null;
                     31:        public $b = null;
                     32: 
                     33:        public function toString() {
                     34:                var_dump($this);
                     35:        }
                     36: }
                     37: 
                     38: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_test'));
                     39: 
                     40: class mysql_fetch_object_construct extends mysql_fetch_object_test {
                     41: 
                     42:        public function __construct($a, $b) {
                     43:                $this->a = $a;
                     44:                $this->b = $b;
                     45:        }
                     46: 
                     47: }
                     48: 
                     49: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', null));
                     50: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a')));
                     51: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b')));
                     52: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b', 'c')));
                     53: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', "no array and not null"));
                     54: var_dump(mysql_fetch_object($res));
                     55: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b')));
                     56: 
                     57: class mysql_fetch_object_private_construct {
                     58:        private function __construct($a, $b) {
                     59:                var_dump($a);
                     60:        }
                     61: }
                     62: var_dump(mysql_fetch_object($res, 'mysql_fetch_object_private_construct', array('a', 'b')));
                     63: 
                     64: mysql_free_result($res);
                     65: 
                     66: if (!$res = mysql_query("SELECT id AS ID, label FROM test AS TEST", $link)) {
                     67:        printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link));
                     68: }
                     69: 
                     70: mysql_free_result($res);
                     71: 
                     72: var_dump(mysql_fetch_object($res));
                     73: 
                     74: // Fatal error, script execution will end
                     75: var_dump(mysql_fetch_object($res, 'this_class_does_not_exist'));
                     76: 
                     77: mysql_close($link);
                     78: print "done!";
                     79: ?>
                     80: --CLEAN--
                     81: <?php
                     82: require_once("clean_table.inc");
                     83: ?>
                     84: --EXPECTF--
                     85: object(stdClass)#%d (2) {
                     86:   [%u|b%"ID"]=>
                     87:   %unicode|string%(1) "1"
                     88:   [%u|b%"label"]=>
                     89:   %unicode|string%(1) "a"
                     90: }
                     91: object(mysql_fetch_object_test)#%d (4) {
                     92:   [%u|b%"a"]=>
                     93:   NULL
                     94:   [%u|b%"b"]=>
                     95:   NULL
                     96:   [%u|b%"ID"]=>
                     97:   %unicode|string%(1) "2"
                     98:   [%u|b%"label"]=>
                     99:   %unicode|string%(1) "b"
                    100: }
                    101: 
                    102: Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d
                    103: 
                    104: Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d
                    105: 
                    106: Notice: Undefined variable: a in %s on line %d
                    107: 
                    108: Notice: Undefined variable: b in %s on line %d
                    109: object(mysql_fetch_object_construct)#%d (4) {
                    110:   [%u|b%"a"]=>
                    111:   NULL
                    112:   [%u|b%"b"]=>
                    113:   NULL
                    114:   [%u|b%"ID"]=>
                    115:   %unicode|string%(1) "3"
                    116:   [%u|b%"label"]=>
                    117:   %unicode|string%(1) "c"
                    118: }
                    119: 
                    120: Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d
                    121: 
                    122: Notice: Undefined variable: b in %s on line %d
                    123: object(mysql_fetch_object_construct)#%d (4) {
                    124:   [%u|b%"a"]=>
                    125:   %unicode|string%(1) "a"
                    126:   [%u|b%"b"]=>
                    127:   NULL
                    128:   [%u|b%"ID"]=>
                    129:   %unicode|string%(1) "4"
                    130:   [%u|b%"label"]=>
                    131:   %unicode|string%(1) "d"
                    132: }
                    133: object(mysql_fetch_object_construct)#%d (4) {
                    134:   [%u|b%"a"]=>
                    135:   %unicode|string%(1) "a"
                    136:   [%u|b%"b"]=>
                    137:   %unicode|string%(1) "b"
                    138:   [%u|b%"ID"]=>
                    139:   %unicode|string%(1) "5"
                    140:   [%u|b%"label"]=>
                    141:   %unicode|string%(1) "e"
                    142: }
                    143: bool(false)
                    144: bool(false)
                    145: bool(false)
                    146: bool(false)
                    147: bool(false)
                    148: 
                    149: Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d
                    150: bool(false)
                    151: 
                    152: Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d

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