PHP 4.0 Bug #5416: MySQL result ids are cleared even while inside a class

From: Date: Thu, 06 Jul 2000 19:29:16 +0000
Subject: PHP 4.0 Bug #5416: MySQL result ids are cleared even while inside a class
Groups: php.dev 
Request: Send a blank email to php-dev+get-23629@lists.php.net to get a copy of this message
From: sean@fifthace.com Operating system: FreeBSD 3.3-RELEASE PHP version: 4.0.1pl2 PHP Bug Type: MySQL related Bug description: MySQL result ids are cleared even while inside a class If I try to run a query in a class constructor and then save the MySQL result id for use later in the class, I can't. It seems that as soon as PHP exits the constructor the MySQL result id is cleaned up and is no longer valid for calls to the class methods. Example (note: not real code :-): mysql_pconnect( blab, blah, blah ); mysql_select_db( ultraBlah ); class MyClass { var $holder; function MyClass( $someparam ) { $this->holder = mysql_query( "select * from a_table" ); } function get_object( ) { return mysql_fetch_object( $this->holder ); } } $o = new MyClass( moreblah ); $row = $o->get_object( ); $row never gets an object and PHP gives an error about $this->holder not being a valid MySQL resource. This is very annoying since it destroyed the entire basis of my current project. I'm assuming this is a bug. At the very least, there should be some sort of option to disable the garbage collection for database stuff while inside a class. If there is a way around it, I'd love to hear about it. Also, as a side rant, it seems constructing objects is a very expensive process in terms of time. That's another problem I ran into. (Although that is probably not a bug so I'm not going to bother reporting it as one) Otherwise, PHP4.0.1pl2 rocks the world. :-)

« previous php.dev (#23629) next »