06-01-2009, 04:45 PM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
Something like this, probably:
PHP Code:
class TestClass { protected $libraries = array(); public function using($name, $obj) { $this->libraries[$name] = $obj; } public function someMethod() { return $this->libraries['db']->query('some query here'); } }
// Example $db = new PDO(...); // create a new db connection...etc, etc.
$myObject = new TestClass(); $myObject->using('db', $db);
var_dump($myObject->someMethod());
This way, you could have all the objects that you want to use at your disposal.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|