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 = 'false'
148client_info = 'false'
149client_version = '%s'
150connect_errno = '%s'
151connect_error = ''%s'
152errno = 'false'
153error = 'false'
154error_list = 'false'
155field_count = 'false'
156host_info = 'false'
157info = 'false'
158insert_id = 'false'
159protocol_version = 'false'
160server_info = 'false'
161server_version = 'false'
162sqlstate = 'false'
163thread_id = 'false'
164warning_count = 'false'
165
166Object variables:
167affected_rows = 'false'
168client_info = 'false'
169client_version = '%s'
170connect_errno = '%s'
171connect_error = '%s'
172errno = 'false'
173error = 'false'
174error_list = 'false'
175field_count = 'false'
176host_info = 'false'
177info = 'false'
178insert_id = 'false'
179server_info = 'false'
180server_version = 'false'
181sqlstate = 'false'
182protocol_version = 'false'
183thread_id = 'false'
184warning_count = 'false'
185
186Magic, magic properties:
187mysqli->affected_rows = ''/boolean (''/boolean)
188
189Warning: assert(): assert(@mysqli_get_client_info() === @$mysqli->client_info) failed in %s on line %d
190mysqli->client_info = ''/boolean ('%s'/%s)
191mysqli->client_version =  '%s'/integer ('%s'/integer)
192mysqli->errno = ''/boolean (''/boolean)
193mysqli->error = ''/boolean (''/boolean)
194mysqli->field_count = ''/boolean (''/boolean)
195mysqli->insert_id = ''/boolean (''/boolean)
196mysqli->sqlstate = ''/boolean (''/boolean)
197mysqli->host_info = ''/boolean (''/boolean)
198mysqli->info = ''/boolean (''/boolean)
199
200Warning: assert(): assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id) failed in %s on line %d
201mysqli->thread_id = ''/boolean (''/boolean)
202mysqli->protocol_version = ''/boolean (''/boolean)
203mysqli->server_info = ''/boolean (''/boolean)
204mysqli->server_version = ''/boolean (''/boolean)
205mysqli->warning_count = ''/boolean (''/boolean)
206
207Access to undefined properties:
208mysqli->unknown = ''
209setting mysqli->unknown, @mysqli_unknown = '13'
210setting mysqli->unknown, @mysqli_unknown = 'friday'
211
212Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
213mysqli->connect_error = '%s'/%s)
214mysqli->connect_errno = '%s'/integer ('%s'/integer)
215With RS
216
217Class variables:
218affected_rows = 'false'
219client_info = 'false'
220client_version = '%s'
221connect_errno = '%s'
222connect_error = '%s'
223errno = 'false'
224error = 'false'
225error_list = 'false'
226field_count = 'false'
227host_info = 'false'
228info = 'false'
229insert_id = 'false'
230protocol_version = 'false'
231server_info = 'false'
232server_version = 'false'
233sqlstate = 'false'
234thread_id = 'false'
235warning_count = 'false'
236
237Object variables:
238affected_rows = 'false'
239client_info = 'false'
240client_version = '%s'
241connect_errno = '%s'
242connect_error = '%s'
243errno = 'false'
244error = 'false'
245error_list = 'false'
246field_count = 'false'
247host_info = 'false'
248info = 'false'
249insert_id = 'false'
250server_info = 'false'
251server_version = 'false'
252sqlstate = 'false'
253protocol_version = 'false'
254thread_id = 'false'
255warning_count = 'false'
256
257Magic, magic properties:
258mysqli->affected_rows = ''/boolean (''/boolean)
259
260Warning: assert(): assert(@mysqli_get_client_info() === @$mysqli->client_info) failed in %s on line %d
261mysqli->client_info = ''/boolean ('%s'/%s)
262mysqli->client_version =  '%s'/integer ('%s'/integer)
263mysqli->errno = ''/boolean (''/boolean)
264mysqli->error = ''/boolean (''/boolean)
265mysqli->field_count = ''/boolean (''/boolean)
266mysqli->insert_id = ''/boolean (''/boolean)
267mysqli->sqlstate = ''/boolean (''/boolean)
268mysqli->host_info = ''/boolean (''/boolean)
269mysqli->info = ''/boolean (''/boolean)
270
271Warning: assert(): assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id) failed in %s on line %d
272mysqli->thread_id = ''/boolean (''/boolean)
273mysqli->protocol_version = ''/boolean (''/boolean)
274mysqli->server_info = ''/boolean (''/boolean)
275mysqli->server_version = ''/boolean (''/boolean)
276mysqli->warning_count = ''/boolean (''/boolean)
277
278Access to undefined properties:
279mysqli->unknown = ''
280setting mysqli->unknown, @mysqli_unknown = '13'
281setting mysqli->unknown, @mysqli_unknown = 'friday'
282
283Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
284mysqli->connect_error = '%s'/%s)
285mysqli->connect_errno = '%s'/integer ('%s'/integer)
286done!
287