jump to navigation

Determining if Zend_DB_Adapter has connected to the database April 20, 2011

Posted by Tournas Dimitrios in Zend Framework v1.10.

For logging and performance tracking we may want to find out if the current Zend_DB_Adapter has connected to the database . The Adapter class doesn’t have a method to return this information . You can create a subclass of the Adapter you need ,  and add a method such as the following:

public function isConnected()
return !is_null($this->_connection);

Another solution if you use the PDO Adapter, is to enable its profiler and look for an entry for ‘connect’ in the resulting query profiles. Even though ‘connect’ isn’t really a statement, the PDO Adapter logs that operation with the query profiler. The non-PDO Adapters don’t do this yet, but there’s no reason why they shouldn’t .

This is the solution that I have found from the zend-framework community , if you have discovered a better solution , please post it on this blog .


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s