~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/mysqli/tests/mysqli_fetch_object_no_constructor.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
        include "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
--EXPECTF--
 
48
No exception with PHP:
 
49
object(mysqli_fetch_object_test)#%d (%d) {
 
50
  [%u|b%"a"]=>
 
51
  NULL
 
52
  [%u|b%"b"]=>
 
53
  NULL
 
54
}
 
55
 
 
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
 
58
 
 
59
Fatal error with PHP (but no exception!):
 
60
 
 
61
Fatal error: Call to undefined method mysqli_fetch_object_test::mysqli_fetch_object_test() in %s on line %d