如何查找现有类实例的命名空间

In this example, the platform used is Magento, but I believe this is a generic question related to Object Oriented Programming.

When a page or API URL is called, the first class to be instantiated will then instantiate other classes, and so forth. I need to change a setting in an instance of one class (there will only be one instance) from within another class.

For example, I am working in class Praxis_Rest_ProductsController::getAction() and want to do this:

(existing instance of Varien_Db_Adapter_Pdo_Mysql)->setDebug(true);

I know for sure that the connection class is Varien_Db_Adapter_Pdo_Mysql and that this is instantiated already, and only once.

How do I do this? Is this possible?

-- EDIT -- @Andrej Ludinovskov below posted a great solution if I know the object name, but in my case, I'm in a spot in the coding which has no relationship too it. In fact it might be 7-10 different classes in the stack downstream where that instantiated object is called; but I do know that class was instantiated and only once for that matter. In this case I'm trying to find $object when all I know is that it's an instance of Varien_Db_Adapter_Pdo_Mysql

Did you try this simple if or I miss something:

if ($object instanceof Varien_Db_Adapter_Pdo_Mysql) {
    $object->setDebug(true);
}