#29311 [Opn->Csd]: Cannot override mysqli constructor

From: Date: Fri, 23 Jul 2004 12:49:12 +0000
Subject: #29311 [Opn->Csd]: Cannot override mysqli constructor
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-63419@lists.php.net to get a copy of this message
 ID:               29311
 Updated by:       georg@php.net
 Reported By:      mc at webheberg dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Class/Object related
 Operating System: Linux Debian
 PHP Version:      5.0.0
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2004-07-22 00:47:06] mc at webheberg dot com

So I use the mysqli procedurial methods in my class (which doesnt
extend mysqli anymore) with a global $link variable. Works fine, but is
not very "PHP5 like".

------------------------------------------------------------------------

[2004-07-21 23:22:21] mc at webheberg dot com

Note that it was working fine with my PHP5 RC2 and the man who reported
http://www.rb21.com/news/index.php?t=rview&th=40368
tells it was also
working fine with RC3

------------------------------------------------------------------------

[2004-07-21 23:16:10] mc at webheberg dot com

Description:
------------
I wrote a small class (named Mysql) that extends mysqli, but when I
make a new Mysql(), it returns :

Fatal error: Can not call constructor in .... which corresponds to line
with parent::__construct

It seems that we can just override mysqli methods, but not the
constructor. I copy paste my code below.

I found someone who recently reported this problem there :
http://www.rb21.com/news/index.php?t=rview&th=40368


and didnt get any response, so I really think it's a bug.

(I'm using PHP5 stable with mysqli, without mysql, and with mysql
4.1.3-beta libraries)

Reproduce code:
---------------
class Mysql extends mysqli {

	static $db_host="*";
	static $db_user="*";
	static $db_pass="*";
	static $db_name="*";
	
	function __construct() {
		parent::__construct(Mysql::$db_host, Mysql::$db_user,
Mysql::$db_pass, Mysql::$db_name);
	}
	
	function query($query) {
	     return parent::query($query);
	}

}a



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29311&edit=1


Thread (4 messages)

« previous php.bugs (#63419) next »