Annotation of embedaddon/php/ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysqli_fetch_object() - calling constructor on class wo constructor
3: --SKIPIF--
4: <?php
5: require_once('skipif.inc');
6: require_once('skipifemb.inc');
7: require_once('skipifconnectfailure.inc');
8: ?>
9: --FILE--
10: <?php
11: require_once("connect.inc");
12:
13: $tmp = NULL;
14: $link = NULL;
15:
16: require('table.inc');
17: if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) {
18: printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
19: }
20:
21: class mysqli_fetch_object_test {
22:
23: public $a = null;
24: public $b = null;
25:
26: public function toString() {
27: var_dump($this);
28: }
29: }
30:
31: printf("No exception with PHP:\n");
32: var_dump($obj = new mysqli_fetch_object_test(1, 2));
33:
34: printf("\nException with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:\n");
35: try {
36: var_dump($obj = mysqli_fetch_object($res, 'mysqli_fetch_object_test', array(1, 2)));
37: } catch (Exception $e) {
38: printf("Exception: %s\n", $e->getMessage());
39: }
40:
41: printf("\nFatal error with PHP (but no exception!):\n");
42: var_dump($obj->mysqli_fetch_object_test(1, 2));
43:
44: mysqli_close($link);
45: print "done!";
46: ?>
47: --CLEAN--
48: <?php
49: require_once("clean_table.inc");
50: ?>
51: --EXPECTF--
52: No exception with PHP:
53: object(mysqli_fetch_object_test)#%d (%d) {
54: [%u|b%"a"]=>
55: NULL
56: [%u|b%"b"]=>
57: NULL
58: }
59:
60: Exception with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:
61: Exception: Class mysqli_fetch_object_test does not have a constructor hence you cannot use ctor_params
62:
63: Fatal error with PHP (but no exception!):
64:
65: Fatal error: Call to undefined method mysqli_fetch_object_test::mysqli_fetch_object_test() in %s on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>