Re: strange mysqli error

From: Date: Wed, 23 Aug 2006 14:06:36 +0000
Subject: Re: strange mysqli error
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-241046@lists.php.net to get a copy of this message
On Aug 23, 2006, at 2:33 AM, Jochem Maas wrote:
how do you know which object is destroyed first? also you are using 3 different versions of php - not something that will help narrow down the problem. Richard K Miller wrote:
Good afternoon. I'm getting a weird mysqli error in my object destructor. Here's an example: <?php $db = new mysqli('localhost', USERNAME, PASSWORD, DATABASE); class Test {
    function __construct()
    {
        global $db;
        $db->query("SELECT 'test'");
        print_r($db->error);
    }
    function __destruct()
    {
        global $db;
        $db->query("SELECT 'test'");  // line 20
        print_r($db->error);  // line 21
    }
} $test = new Test();
what happens if you add the following line: unset($test);
No errors when I use unset(). I see what you mean about not knowing which object is destroyed first. Maybe I'll have to use a non-OOP connection to MySQL, since it wouldn't appear there's any way to specify the order of destruction of objects.

« previous php.general (#241046) next »