2
mysqli_fetch_object() - calling constructor on class wo constructor
5
require_once('skipif.inc');
6
require_once('skipifemb.inc');
7
require_once('skipifconnectfailure.inc');
11
include "connect.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));
21
class mysqli_fetch_object_test {
26
public function toString() {
31
printf("No exception with PHP:\n");
32
var_dump($obj = new mysqli_fetch_object_test(1, 2));
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");
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());
41
printf("\nFatal error with PHP (but no exception!):\n");
42
var_dump($obj->mysqli_fetch_object_test(1, 2));
48
No exception with PHP:
49
object(mysqli_fetch_object_test)#%d (%d) {
56
Exception with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:
57
Exception: Class mysqli_fetch_object_test does not have a constructor hence you cannot use ctor_params
59
Fatal error with PHP (but no exception!):
61
Fatal error: Call to undefined method mysqli_fetch_object_test::mysqli_fetch_object_test() in %s on line %d