1--TEST--
2Interface of the class mysqli
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
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            try {
20                printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
21            } catch (Error $exception) {
22                echo $exception->getMessage() . "\n";
23            }
24        }
25
26        printf("\nObject variables:\n");
27        $variables = array_keys(get_object_vars($mysqli));
28        foreach ($variables as $k => $var) {
29            try {
30                printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
31            } catch (Error $exception) {
32                echo $exception->getMessage() . "\n";
33            }
34        }
35
36        printf("\nMagic, magic properties:\n");
37        try {
38            mysqli_affected_rows($mysqli);
39        } catch (Error $exception) {
40            echo $exception->getMessage() . "\n";
41        }
42
43        try {
44            $mysqli->affected_rows;
45        } catch (Error $exception) {
46            echo $exception->getMessage() . "\n";
47        }
48
49        printf("mysqli->client_info = '%s'/%s\n", $mysqli->client_info, gettype($mysqli->client_info));
50
51        printf("mysqli->client_version = '%s'/%s\n", $mysqli->client_version, gettype($mysqli->client_version));
52
53        try {
54            mysqli_errno($mysqli);
55        } catch (Error $exception) {
56            echo $exception->getMessage() . "\n";
57        }
58
59        try {
60            $mysqli->errno;
61        } catch (Error $exception) {
62            echo $exception->getMessage() . "\n";
63        }
64
65        try {
66            mysqli_error($mysqli);
67        } catch (Error $exception) {
68            echo $exception->getMessage() . "\n";
69        }
70
71        try {
72            $mysqli->error;
73        } catch (Error $exception) {
74            echo $exception->getMessage() . "\n";
75        }
76
77        try {
78            mysqli_field_count($mysqli);
79        } catch (Error $exception) {
80            echo $exception->getMessage() . "\n";
81        }
82
83        try {
84            $mysqli->field_count;
85        } catch (Error $exception) {
86            echo $exception->getMessage() . "\n";
87        }
88
89        try {
90            mysqli_insert_id($mysqli);
91        } catch (Error $exception) {
92            echo $exception->getMessage() . "\n";
93        }
94
95        try {
96            $mysqli->insert_id;
97        } catch (Error $exception) {
98            echo $exception->getMessage() . "\n";
99        }
100
101        try {
102            mysqli_sqlstate($mysqli);
103        } catch (Error $exception) {
104            echo $exception->getMessage() . "\n";
105        }
106
107        try {
108            $mysqli->sqlstate;
109        } catch (Error $exception) {
110            echo $exception->getMessage() . "\n";
111        }
112
113        try {
114            mysqli_get_host_info($mysqli);
115        } catch (Error $exception) {
116            echo $exception->getMessage() . "\n";
117        }
118
119        try {
120            $mysqli->host_info;
121        } catch (Error $exception) {
122            echo $exception->getMessage() . "\n";
123        }
124
125        try {
126            mysqli_info($mysqli);
127        } catch (Error $exception) {
128            echo $exception->getMessage() . "\n";
129        }
130
131        try {
132            $mysqli->info;
133        } catch (Error $exception) {
134            echo $exception->getMessage() . "\n";
135        }
136
137        try {
138            mysqli_thread_id($mysqli);
139        } catch (Error $exception) {
140            echo $exception->getMessage() . "\n";
141        }
142
143        try {
144            $mysqli->thread_id;
145        } catch (Error $exception) {
146            echo $exception->getMessage() . "\n";
147        }
148
149        try {
150            mysqli_get_proto_info($mysqli);
151        } catch (Error $exception) {
152            echo $exception->getMessage() . "\n";
153        }
154
155        try {
156            $mysqli->protocol_version;
157        } catch (Error $exception) {
158            echo $exception->getMessage() . "\n";
159        }
160
161        try {
162            mysqli_get_server_info($mysqli);
163        } catch (Error $exception) {
164            echo $exception->getMessage() . "\n";
165        }
166
167        try {
168            $mysqli->server_info;
169        } catch (Error $exception) {
170            echo $exception->getMessage() . "\n";
171        }
172
173        try {
174            mysqli_get_server_version($mysqli);
175        } catch (Error $exception) {
176            echo $exception->getMessage() . "\n";
177        }
178
179        try {
180            $mysqli->server_version;
181        } catch (Error $exception) {
182            echo $exception->getMessage() . "\n";
183        }
184
185        try {
186            mysqli_warning_count($mysqli);
187        } catch (Error $exception) {
188            echo $exception->getMessage() . "\n";
189        }
190
191        try {
192            $mysqli->warning_count;
193        } catch (Error $exception) {
194            echo $exception->getMessage() . "\n";
195        }
196
197
198        printf("\nAccess to undefined properties:\n");
199        printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
200
201        @$mysqli->unknown = 13;
202        printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
203
204        $unknown = 'friday';
205        @$mysqli->unknown = $unknown;
206        printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
207
208        printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
209        assert(@mysqli_connect_error() === @$mysqli->connect_error);
210        printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n",
211            @$mysqli->connect_error, gettype(@$mysqli->connect_error),
212            @mysqli_connect_error(), gettype(@mysqli_connect_error()));
213
214        assert(@mysqli_connect_errno() === @$mysqli->connect_errno);
215        printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n",
216            @$mysqli->connect_errno, gettype(@$mysqli->connect_errno),
217            @mysqli_connect_errno(), gettype(@mysqli_connect_errno()));
218    }
219
220    printf("Without RS\n");
221    $mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
222    dump_properties($mysqli);
223
224    printf("\nWith RS\n");
225    $mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
226    try {
227        $mysqli->query("SELECT * FROM test");
228    } catch (Error $exception) {
229        echo $exception->getMessage() . "\n";
230    }
231    dump_properties($mysqli);
232
233    print "done!";
234?>
235--CLEAN--
236<?php require_once 'clean_table.inc'; ?>
237--EXPECTF--
238Without RS
239
240Class variables:
241Property access is not allowed yet
242client_info = '%s'
243client_version = '%s'
244connect_errno = '%s'
245connect_error = ''%s'
246mysqli object is already closed
247mysqli object is already closed
248Property access is not allowed yet
249mysqli object is already closed
250mysqli object is already closed
251mysqli object is already closed
252mysqli object is already closed
253mysqli object is already closed
254mysqli object is already closed
255mysqli object is already closed
256mysqli object is already closed
257mysqli object is already closed
258mysqli object is already closed
259
260Object variables:
261
262Magic, magic properties:
263mysqli object is already closed
264Property access is not allowed yet
265mysqli->client_info = '%s'/string
266mysqli->client_version = '%d'/integer
267mysqli object is already closed
268mysqli object is already closed
269mysqli object is already closed
270mysqli object is already closed
271mysqli object is already closed
272mysqli object is already closed
273mysqli object is already closed
274mysqli object is already closed
275mysqli object is already closed
276mysqli object is already closed
277mysqli object is already closed
278mysqli object is already closed
279mysqli object is already closed
280mysqli object is already closed
281mysqli object is already closed
282mysqli object is already closed
283mysqli object is already closed
284mysqli object is already closed
285mysqli object is already closed
286mysqli object is already closed
287mysqli object is already closed
288mysqli object is already closed
289mysqli object is already closed
290mysqli object is already closed
291
292Access to undefined properties:
293mysqli->unknown = ''
294setting mysqli->unknown, @mysqli_unknown = '13'
295setting mysqli->unknown, @mysqli_unknown = 'friday'
296
297Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
298mysqli->connect_error = '%s'/%s)
299mysqli->connect_errno = '%s'/integer ('%s'/integer)
300
301With RS
302mysqli object is already closed
303
304Class variables:
305Property access is not allowed yet
306client_info = '%s'
307client_version = '%s'
308connect_errno = '%s'
309connect_error = '%s'
310mysqli object is already closed
311mysqli object is already closed
312Property access is not allowed yet
313mysqli object is already closed
314mysqli object is already closed
315mysqli object is already closed
316mysqli object is already closed
317mysqli object is already closed
318mysqli object is already closed
319mysqli object is already closed
320mysqli object is already closed
321mysqli object is already closed
322mysqli object is already closed
323
324Object variables:
325
326Magic, magic properties:
327mysqli object is already closed
328Property access is not allowed yet
329mysqli->client_info = '%s'/string
330mysqli->client_version = '%d'/integer
331mysqli object is already closed
332mysqli object is already closed
333mysqli object is already closed
334mysqli object is already closed
335mysqli object is already closed
336mysqli object is already closed
337mysqli object is already closed
338mysqli object is already closed
339mysqli object is already closed
340mysqli object is already closed
341mysqli object is already closed
342mysqli object is already closed
343mysqli object is already closed
344mysqli object is already closed
345mysqli object is already closed
346mysqli object is already closed
347mysqli object is already closed
348mysqli object is already closed
349mysqli object is already closed
350mysqli object is already closed
351mysqli object is already closed
352mysqli object is already closed
353mysqli object is already closed
354mysqli object is already closed
355
356Access to undefined properties:
357mysqli->unknown = ''
358setting mysqli->unknown, @mysqli_unknown = '13'
359setting mysqli->unknown, @mysqli_unknown = 'friday'
360
361Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
362mysqli->connect_error = '%s'/%s)
363mysqli->connect_errno = '%s'/integer ('%s'/integer)
364done!
365