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-- 85object(stdClass)#%d (2) { 86 [%u|b%"ID"]=> 87 %unicode|string%(1) "1" 88 [%u|b%"label"]=> 89 %unicode|string%(1) "a" 90} 91object(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 102Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d 103 104Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d 105 106Notice: Undefined variable: a in %s on line %d 107 108Notice: Undefined variable: b in %s on line %d 109object(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 120Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d 121 122Notice: Undefined variable: b in %s on line %d 123object(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} 133object(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} 143bool(false) 144bool(false) 145bool(false) 146bool(false) 147bool(false) 148 149Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d 150bool(false) 151 152Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d 153