View Single Post
Old 06-01-2009, 04:45 PM   #2 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

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.
xenon is offline  
Reply With Quote