我有以下代码:
class db {
//database class, connects and closes a database connection
//some properties and methods are hided (such as host-adres, username...)
public function connect()
{
mysql_connect(//parameters)or die(mysql_error());
}
}
class ban {
//ban class, bans an ip, again some methods and properties are hided
public function banIP()
{
//here i want to access the connect function of the class db,
//without creating a object.
//some code
}
}
现在我的问题是,从我需要使用类 dbbanIP()
中的函数连接到数据库的方法内部。connect()
但是如何访问连接功能?