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_get_host_info($mysqli) === @$mysqli->host_info);
72		printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n",
73			@$mysqli->host_info, gettype(@$mysqli->host_info),
74			@mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli)));
75
76		/* note that the data types are different */
77		assert(@mysqli_info($mysqli) == @$mysqli->info);
78		printf("mysqli->info = '%s'/%s ('%s'/%s)\n",
79			@$mysqli->info, gettype(@$mysqli->info),
80			@mysqli_info($mysqli), gettype(@mysqli_info($mysqli)));
81
82		assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id);
83		assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli)));
84		printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n",
85			@$mysqli->thread_id, gettype(@$mysqli->thread_id),
86			@mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli)));
87
88		assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version);
89		printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n",
90			@$mysqli->protocol_version, gettype(@$mysqli->protocol_version),
91			@mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli)));
92
93		assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info);
94		printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n",
95			@$mysqli->server_info, gettype(@$mysqli->server_info),
96			@mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli)));
97
98		assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version);
99		printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n",
100			@$mysqli->server_version, gettype(@$mysqli->server_version),
101			@mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli)));
102
103		assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count);
104		printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n",
105			@$mysqli->warning_count, gettype(@$mysqli->warning_count),
106			@mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli)));
107
108		printf("\nAccess to undefined properties:\n");
109		printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
110
111		@$mysqli->unknown = 13;
112		printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
113
114		$unknown = 'friday';
115		@$mysqli->unknown = $unknown;
116		printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
117
118		printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
119		assert(@mysqli_connect_error() === @$mysqli->connect_error);
120		printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n",
121			@$mysqli->connect_error, gettype(@$mysqli->connect_error),
122			@mysqli_connect_error(), gettype(@mysqli_connect_error()));
123
124		assert(@mysqli_connect_errno() === @$mysqli->connect_errno);
125		printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n",
126			@$mysqli->connect_errno, gettype(@$mysqli->connect_errno),
127			@mysqli_connect_errno(), gettype(@mysqli_connect_errno()));
128	}
129
130	printf("Without RS\n");
131	$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
132	dump_properties($mysqli);
133
134	printf("With RS\n");
135	$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
136	$res = @$mysqli->query("SELECT * FROM test");
137	dump_properties($mysqli);
138
139	print "done!";
140?>
141--CLEAN--
142<?php require_once("clean_table.inc"); ?>
143--EXPECTF--
144Without RS
145
146Class variables:
147affected_rows = 'NULL'
148client_info = 'NULL'
149client_version = '%s'
150connect_errno = '%s'
151connect_error = ''%s'
152errno = 'NULL'
153error = 'NULL'
154error_list = 'NULL'
155field_count = 'NULL'
156host_info = 'NULL'
157info = 'NULL'
158insert_id = 'NULL'
159protocol_version = 'NULL'
160server_info = 'NULL'
161server_version = 'NULL'
162sqlstate = 'NULL'
163stat = 'NULL'
164thread_id = 'NULL'
165warning_count = 'NULL'
166
167Object variables:
168affected_rows = 'NULL'
169client_info = 'NULL'
170client_version = '%s'
171connect_errno = '%s'
172connect_error = '%s'
173errno = 'NULL'
174error = 'NULL'
175error_list = 'NULL'
176field_count = 'NULL'
177host_info = 'NULL'
178info = 'NULL'
179insert_id = 'NULL'
180server_info = 'NULL'
181server_version = 'NULL'
182stat = 'NULL'
183sqlstate = 'NULL'
184protocol_version = 'NULL'
185thread_id = 'NULL'
186warning_count = 'NULL'
187
188Magic, magic properties:
189mysqli->affected_rows = ''/NULL (''/NULL)
190
191Warning: assert(): Assertion failed in %s on line %d
192mysqli->client_info = ''/NULL ('%s'/%s)
193mysqli->client_version =  '%s'/integer ('%s'/integer)
194mysqli->errno = ''/NULL (''/NULL)
195mysqli->error = ''/NULL (''/NULL)
196mysqli->field_count = ''/NULL (''/NULL)
197mysqli->insert_id = ''/NULL (''/NULL)
198mysqli->sqlstate = ''/NULL (''/NULL)
199mysqli->host_info = ''/NULL (''/NULL)
200mysqli->info = ''/NULL (''/NULL)
201
202Warning: assert(): Assertion failed in %s on line %d
203mysqli->thread_id = ''/NULL (''/NULL)
204mysqli->protocol_version = ''/NULL (''/NULL)
205mysqli->server_info = ''/NULL (''/NULL)
206mysqli->server_version = ''/NULL (''/NULL)
207mysqli->warning_count = ''/NULL (''/NULL)
208
209Access to undefined properties:
210mysqli->unknown = ''
211setting mysqli->unknown, @mysqli_unknown = '13'
212setting mysqli->unknown, @mysqli_unknown = 'friday'
213
214Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
215mysqli->connect_error = '%s'/%s)
216mysqli->connect_errno = '%s'/integer ('%s'/integer)
217With RS
218
219Class variables:
220affected_rows = 'NULL'
221client_info = 'NULL'
222client_version = '%s'
223connect_errno = '%s'
224connect_error = '%s'
225errno = 'NULL'
226error = 'NULL'
227error_list = 'NULL'
228field_count = 'NULL'
229host_info = 'NULL'
230info = 'NULL'
231insert_id = 'NULL'
232protocol_version = 'NULL'
233server_info = 'NULL'
234server_version = 'NULL'
235sqlstate = 'NULL'
236stat = 'NULL'
237thread_id = 'NULL'
238warning_count = 'NULL'
239
240Object variables:
241affected_rows = 'NULL'
242client_info = 'NULL'
243client_version = '%s'
244connect_errno = '%s'
245connect_error = '%s'
246errno = 'NULL'
247error = 'NULL'
248error_list = 'NULL'
249field_count = 'NULL'
250host_info = 'NULL'
251info = 'NULL'
252insert_id = 'NULL'
253server_info = 'NULL'
254server_version = 'NULL'
255stat = 'NULL'
256sqlstate = 'NULL'
257protocol_version = 'NULL'
258thread_id = 'NULL'
259warning_count = 'NULL'
260
261Magic, magic properties:
262mysqli->affected_rows = ''/NULL (''/NULL)
263
264Warning: assert(): Assertion failed in %s on line %d
265mysqli->client_info = ''/NULL ('%s'/%s)
266mysqli->client_version =  '%s'/integer ('%s'/integer)
267mysqli->errno = ''/NULL (''/NULL)
268mysqli->error = ''/NULL (''/NULL)
269mysqli->field_count = ''/NULL (''/NULL)
270mysqli->insert_id = ''/NULL (''/NULL)
271mysqli->sqlstate = ''/NULL (''/NULL)
272mysqli->host_info = ''/NULL (''/NULL)
273mysqli->info = ''/NULL (''/NULL)
274
275Warning: assert(): Assertion failed in %s on line %d
276mysqli->thread_id = ''/NULL (''/NULL)
277mysqli->protocol_version = ''/NULL (''/NULL)
278mysqli->server_info = ''/NULL (''/NULL)
279mysqli->server_version = ''/NULL (''/NULL)
280mysqli->warning_count = ''/NULL (''/NULL)
281
282Access to undefined properties:
283mysqli->unknown = ''
284setting mysqli->unknown, @mysqli_unknown = '13'
285setting mysqli->unknown, @mysqli_unknown = 'friday'
286
287Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
288mysqli->connect_error = '%s'/%s)
289mysqli->connect_errno = '%s'/integer ('%s'/integer)
290done!