I have a question about singleton design pattern and name of class as variable.
I have a config file with value like this:
$config["database_class _name"]="MyProjectData baseHandler"
Then I aslo have class MyProjectDataba seHandler, witch is Singleton, where i handle everything connected with database
And finally I have second class, and I would like to work it like this:
class MyClass{
public function foo(){
$GLOBALS["config"]["database_class _name"]::get_instance( )->query($query ); //should work same as: MyProjectDataba seHandler::get_ instance()->query($query )
}
}
But it doesn't work. May I ask for a right way how to write a name of singleton class as variable?
I have a config file with value like this:
$config["database_class _name"]="MyProjectData baseHandler"
Then I aslo have class MyProjectDataba seHandler, witch is Singleton, where i handle everything connected with database
And finally I have second class, and I would like to work it like this:
class MyClass{
public function foo(){
$GLOBALS["config"]["database_class _name"]::get_instance( )->query($query ); //should work same as: MyProjectDataba seHandler::get_ instance()->query($query )
}
}
But it doesn't work. May I ask for a right way how to write a name of singleton class as variable?
Comment