1--TEST-- 2mysql_fetch_object() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifconnectfailure.inc'); 7?> 8--FILE-- 9<?php 10include "connect.inc"; 11 12$tmp = NULL; 13$link = NULL; 14 15if (!is_null($tmp = @mysql_fetch_object())) 16 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 17 18if (false !== ($tmp = @mysql_fetch_object($link))) 19 printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 20 21require('table.inc'); 22if (!$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 26var_dump(mysql_fetch_object($res)); 27 28class 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 38var_dump(mysql_fetch_object($res, 'mysql_fetch_object_test')); 39 40class 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 49var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', null)); 50var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a'))); 51var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b'))); 52var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b', 'c'))); 53var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', "no array and not null")); 54var_dump(mysql_fetch_object($res)); 55var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b'))); 56 57class mysql_fetch_object_private_construct { 58 private function __construct($a, $b) { 59 var_dump($a); 60 } 61} 62var_dump(mysql_fetch_object($res, 'mysql_fetch_object_private_construct', array('a', 'b'))); 63 64mysql_free_result($res); 65 66if (!$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 70mysql_free_result($res); 71 72var_dump(mysql_fetch_object($res)); 73 74// Fatal error, script execution will end 75var_dump(mysql_fetch_object($res, 'this_class_does_not_exist')); 76 77mysql_close($link); 78print "done!"; 79?> 80--CLEAN-- 81<?php 82require_once("clean_table.inc"); 83?> 84--EXPECTF-- 85Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d 86object(stdClass)#%d (2) { 87 [%u|b%"ID"]=> 88 %unicode|string%(1) "1" 89 [%u|b%"label"]=> 90 %unicode|string%(1) "a" 91} 92object(mysql_fetch_object_test)#%d (4) { 93 [%u|b%"a"]=> 94 NULL 95 [%u|b%"b"]=> 96 NULL 97 [%u|b%"ID"]=> 98 %unicode|string%(1) "2" 99 [%u|b%"label"]=> 100 %unicode|string%(1) "b" 101} 102 103Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d 104 105Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d 106 107Notice: Undefined variable: a in %s on line %d 108 109Notice: Undefined variable: b in %s on line %d 110object(mysql_fetch_object_construct)#%d (4) { 111 [%u|b%"a"]=> 112 NULL 113 [%u|b%"b"]=> 114 NULL 115 [%u|b%"ID"]=> 116 %unicode|string%(1) "3" 117 [%u|b%"label"]=> 118 %unicode|string%(1) "c" 119} 120 121Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d 122 123Notice: Undefined variable: b in %s on line %d 124object(mysql_fetch_object_construct)#%d (4) { 125 [%u|b%"a"]=> 126 %unicode|string%(1) "a" 127 [%u|b%"b"]=> 128 NULL 129 [%u|b%"ID"]=> 130 %unicode|string%(1) "4" 131 [%u|b%"label"]=> 132 %unicode|string%(1) "d" 133} 134object(mysql_fetch_object_construct)#%d (4) { 135 [%u|b%"a"]=> 136 %unicode|string%(1) "a" 137 [%u|b%"b"]=> 138 %unicode|string%(1) "b" 139 [%u|b%"ID"]=> 140 %unicode|string%(1) "5" 141 [%u|b%"label"]=> 142 %unicode|string%(1) "e" 143} 144bool(false) 145bool(false) 146bool(false) 147bool(false) 148bool(false) 149 150Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d 151bool(false) 152 153Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d 154