1--TEST--
2Interface of the class mysqli
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifemb.inc');
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11	require('table.inc');
12
13	function dump_properties($mysqli) {
14
15		printf("\nClass variables:\n");
16		$variables = array_keys(get_class_vars(get_class($mysqli)));
17		sort($variables);
18		foreach ($variables as $k => $var) {
19			printf("%s = '%s'\n", $var, var_export(@$mysqli->$var, true));
20		}
21
22		printf("\nObject variables:\n");
23		$variables = array_keys(get_object_vars($mysqli));
24		foreach ($variables as $k => $var) {
25			printf("%s = '%s'\n", $var, var_export(@$mysqli->$var, true));
26		}
27
28		printf("\nMagic, magic properties:\n");
29
30		assert(@mysqli_affected_rows($mysqli) === @$mysqli->affected_rows);
31		printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n",
32			@$mysqli->affected_rows, gettype(@$mysqli->affected_rows),
33			@mysqli_affected_rows($mysqli), gettype(@mysqli_affected_rows($mysqli)));
34
35		assert(@mysqli_get_client_info() === @$mysqli->client_info);
36		printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n",
37			@$mysqli->client_info, gettype(@$mysqli->client_info),
38			@mysqli_get_client_info(), gettype(@mysqli_get_client_info()));
39
40		assert(@mysqli_get_client_version() === @$mysqli->client_version);
41		printf("mysqli->client_version =  '%s'/%s ('%s'/%s)\n",
42			@$mysqli->client_version, gettype(@$mysqli->client_version),
43			@mysqli_get_client_version(), gettype(@mysqli_get_client_version()));
44
45		assert(@mysqli_errno($mysqli) === @$mysqli->errno);
46		printf("mysqli->errno = '%s'/%s ('%s'/%s)\n",
47			@$mysqli->errno, gettype(@$mysqli->errno),
48
49			@mysqli_errno($mysqli), gettype(@mysqli_errno($mysqli)));
50
51		assert(@mysqli_error($mysqli) === @$mysqli->error);
52		printf("mysqli->error = '%s'/%s ('%s'/%s)\n",
53			@$mysqli->error, gettype(@$mysqli->error),
54			@mysqli_error($mysqli), gettype(@mysqli_error($mysqli)));
55
56		assert(@mysqli_field_count($mysqli) === @$mysqli->field_count);
57		printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n",
58			@$mysqli->field_count, gettype(@$mysqli->field_count),
59			@mysqli_field_count($mysqli), gettype(@mysqli_field_count($mysqli)));
60
61		assert(@mysqli_insert_id($mysqli) === @$mysqli->insert_id);
62		printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n",
63			@$mysqli->insert_id, gettype(@$mysqli->insert_id),
64			@mysqli_insert_id($mysqli), gettype(@mysqli_insert_id($mysqli)));
65
66		assert(@mysqli_sqlstate($mysqli) === @$mysqli->sqlstate);
67		printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n",
68			@$mysqli->sqlstate, gettype(@$mysqli->sqlstate),
69			@mysqli_sqlstate($mysqli), gettype(@mysqli_sqlstate($mysqli)));
70
71		assert(@mysqli_stat($mysqli) === @$mysqli->sstat);
72		printf("mysqli->stat = '%s'/%s ('%s'/%s)\n",
73			@$mysqli->stat, gettype(@$mysqli->stat),
74			@mysqli_stat($mysqli), gettype(@mysqli_stat($mysqli)));
75
76		assert(@mysqli_get_host_info($mysqli) === @$mysqli->host_info);
77		printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n",
78			@$mysqli->host_info, gettype(@$mysqli->host_info),
79			@mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli)));
80
81		/* note that the data types are different */
82		assert(@mysqli_info($mysqli) == @$mysqli->info);
83		printf("mysqli->info = '%s'/%s ('%s'/%s)\n",
84			@$mysqli->info, gettype(@$mysqli->info),
85			@mysqli_info($mysqli), gettype(@mysqli_info($mysqli)));
86
87		assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id);
88		assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli)));
89		printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n",
90			@$mysqli->thread_id, gettype(@$mysqli->thread_id),
91			@mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli)));
92
93		assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version);
94		printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n",
95			@$mysqli->protocol_version, gettype(@$mysqli->protocol_version),
96			@mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli)));
97
98		assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info);
99		printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n",
100			@$mysqli->server_info, gettype(@$mysqli->server_info),
101			@mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli)));
102
103		assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version);
104		printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n",
105			@$mysqli->server_version, gettype(@$mysqli->server_version),
106			@mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli)));
107
108		assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count);
109		printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n",
110			@$mysqli->warning_count, gettype(@$mysqli->warning_count),
111			@mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli)));
112
113		printf("\nAccess to undefined properties:\n");
114		printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
115
116		@$mysqli->unknown = 13;
117		printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
118
119		$unknown = 'friday';
120		@$mysqli->unknown = $unknown;
121		printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
122
123		printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
124		assert(@mysqli_connect_error() === @$mysqli->connect_error);
125		printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n",
126			@$mysqli->connect_error, gettype(@$mysqli->connect_error),
127			@mysqli_connect_error(), gettype(@mysqli_connect_error()));
128
129		assert(@mysqli_connect_errno() === @$mysqli->connect_errno);
130		printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n",
131			@$mysqli->connect_errno, gettype(@$mysqli->connect_errno),
132			@mysqli_connect_errno(), gettype(@mysqli_connect_errno()));
133	}
134
135	printf("Without RS\n");
136	$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
137	dump_properties($mysqli);
138
139	printf("With RS\n");
140	$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
141	$res = @$mysqli->query("SELECT * FROM test");
142	dump_properties($mysqli);
143
144	print "done!";
145?>
146--CLEAN--
147<?php require_once("clean_table.inc"); ?>
148--EXPECTF--
149Without RS
150
151Class variables:
152affected_rows = 'NULL'
153client_info = 'NULL'
154client_version = '%d'
155connect_errno = '%d'
156connect_error = '%s'
157errno = 'NULL'
158error = 'NULL'
159field_count = 'NULL'
160host_info = 'NULL'
161info = 'NULL'
162insert_id = 'NULL'
163protocol_version = 'NULL'
164server_info = 'NULL'
165server_version = 'NULL'
166sqlstate = 'NULL'
167stat = 'NULL'
168thread_id = 'NULL'
169warning_count = 'NULL'
170
171Object variables:
172affected_rows = 'NULL'
173client_info = 'NULL'
174client_version = '%d'
175connect_errno = '%d'
176connect_error = '%s'
177errno = 'NULL'
178error = 'NULL'
179field_count = 'NULL'
180host_info = 'NULL'
181info = 'NULL'
182insert_id = 'NULL'
183server_info = 'NULL'
184server_version = 'NULL'
185stat = 'NULL'
186sqlstate = 'NULL'
187protocol_version = 'NULL'
188thread_id = 'NULL'
189warning_count = 'NULL'
190
191Magic, magic properties:
192mysqli->affected_rows = ''/NULL (''/NULL)
193
194Warning: assert(): Assertion failed in %s on line %d
195mysqli->client_info = ''/NULL ('%s'/string)
196mysqli->client_version =  '%d'/integer ('%d'/integer)
197mysqli->errno = ''/NULL (''/NULL)
198mysqli->error = ''/NULL (''/NULL)
199mysqli->field_count = ''/NULL (''/NULL)
200mysqli->insert_id = ''/NULL (''/NULL)
201mysqli->sqlstate = ''/NULL (''/NULL)
202mysqli->stat = ''/NULL (''/NULL)
203mysqli->host_info = ''/NULL (''/NULL)
204mysqli->info = ''/NULL (''/NULL)
205
206Warning: assert(): Assertion failed in %s on line 78
207mysqli->thread_id = ''/NULL (''/NULL)
208mysqli->protocol_version = ''/NULL (''/NULL)
209mysqli->server_info = ''/NULL (''/NULL)
210mysqli->server_version = ''/NULL (''/NULL)
211mysqli->warning_count = ''/NULL (''/NULL)
212
213Access to undefined properties:
214mysqli->unknown = ''
215setting mysqli->unknown, @mysqli_unknown = '13'
216setting mysqli->unknown, @mysqli_unknown = 'friday'
217
218Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
219mysqli->connect_error = '%s'/string ('%s'/string)
220mysqli->connect_errno = '%d'/integer ('%d'/integer)
221With RS
222
223Class variables:
224affected_rows = 'NULL'
225client_info = 'NULL'
226client_version = '%d'
227connect_errno = '%d'
228connect_error = '%s'
229errno = 'NULL'
230error = 'NULL'
231field_count = 'NULL'
232host_info = 'NULL'
233info = 'NULL'
234insert_id = 'NULL'
235protocol_version = 'NULL'
236server_info = 'NULL'
237server_version = 'NULL'
238sqlstate = 'NULL'
239stat = 'NULL'
240thread_id = 'NULL'
241warning_count = 'NULL'
242
243Object variables:
244affected_rows = 'NULL'
245client_info = 'NULL'
246client_version = '%d'
247connect_errno = '%d'
248connect_error = '%s'
249errno = 'NULL'
250error = 'NULL'
251field_count = 'NULL'
252host_info = 'NULL'
253info = 'NULL'
254insert_id = 'NULL'
255server_info = 'NULL'
256server_version = 'NULL'
257stat = 'NULL'
258sqlstate = 'NULL'
259protocol_version = 'NULL'
260thread_id = 'NULL'
261warning_count = 'NULL'
262
263Magic, magic properties:
264mysqli->affected_rows = ''/NULL (''/NULL)
265
266Warning: assert(): Assertion failed in %s on line %s
267mysqli->client_info = ''/NULL ('%s'/string)
268mysqli->client_version =  '%d'/integer ('%d'/integer)
269mysqli->errno = ''/NULL (''/NULL)
270mysqli->error = ''/NULL (''/NULL)
271mysqli->field_count = ''/NULL (''/NULL)
272mysqli->insert_id = ''/NULL (''/NULL)
273mysqli->sqlstate = ''/NULL (''/NULL)
274mysqli->stat = ''/NULL (''/NULL)
275mysqli->host_info = ''/NULL (''/NULL)
276mysqli->info = ''/NULL (''/NULL)
277
278Warning: assert(): Assertion failed in %s on line %d
279mysqli->thread_id = ''/NULL (''/NULL)
280mysqli->protocol_version = ''/NULL (''/NULL)
281mysqli->server_info = ''/NULL (''/NULL)
282mysqli->server_version = ''/NULL (''/NULL)
283mysqli->warning_count = ''/NULL (''/NULL)
284
285Access to undefined properties:
286mysqli->unknown = ''
287setting mysqli->unknown, @mysqli_unknown = '13'
288setting mysqli->unknown, @mysqli_unknown = 'friday'
289
290Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
291mysqli->connect_error = '%s'/string ('%s'/string)
292mysqli->connect_errno = '%d'/integer ('%d'/integer)
293done!