Singleton vs CodeIgniter -style $this to access variables

giggs11

New Member
I wonder, what are the pros and the cons of these two approaches to access variables:1) CodeIgniter -style (does this have a name?)\[code\]public function doSomething(){ $database = $this->database; // or just $this->database}\[/code\]2) The Singleton pattern\[code\]public function doSomething(){ $database = Framework_Database::getInstance();}\[/code\]One obvious difference is that with Singleton, you can't modify it. You can only access it, but I'm talking about here only in the aspect of accessing an instance of a class or a variable.Oh, and, are there other approaches?
 
Back
Top