Index: class.ux_t3lib_db.php =================================================================== --- class.ux_t3lib_db.php (revision 32189) +++ class.ux_t3lib_db.php (working copy) @@ -2580,6 +2606,26 @@ /** + * Checks if database is connected. + * + * @return·boolean + */ + public function isConnected() { + $result = FALSE; + switch ((string)$this->handlerCfg[$this->lastHandlerKey]['type']) { + case 'native': + $result = is_resource($this->link); + break; + case 'adodb': + case 'userdefined': + $result = is_object($this->handlerInstance[$this->lastHandlerKey]) && $this->handlerInstance[$this->lastHandlerKey]->isConnected(); + break; + } + return $result; + } + + + /** * Checks whether the DBAL is currently inside an operation running on the "native" DB handler (i.e. MySQL) * * @return boolean True if running on "native" DB handler (i.e. MySQL) Index: tests/db_mssql_testcase.php =================================================================== --- tests/db_mssql_testcase.php (revision 32189) +++ tests/db_mssql_testcase.php (working copy) @@ -64,10 +64,12 @@ $parserClassName = self::buildAccessibleProxy('ux_t3lib_sqlparser'); $GLOBALS['TYPO3_DB']->SQLparser = new $parserClassName; + $this->assertFalse($GLOBALS['TYPO3_DB']->isConnected()); + // Initialize a fake MS SQL connection FakeDbConnection::connect($GLOBALS['TYPO3_DB'], 'mssql'); - $this->assertTrue($GLOBALS['TYPO3_DB']->handlerInstance['_DEFAULT']->isConnected()); + $this->assertTrue($GLOBALS['TYPO3_DB']->isConnected()); } /** Index: tests/db_postgresql_testcase.php =================================================================== --- tests/db_postgresql_testcase.php (revision 32189) +++ tests/db_postgresql_testcase.php (working copy) @@ -64,10 +64,12 @@ $parserClassName = self::buildAccessibleProxy('ux_t3lib_sqlparser'); $GLOBALS['TYPO3_DB']->SQLparser = new $parserClassName; + $this->assertFalse($GLOBALS['TYPO3_DB']->isConnected()); + // Initialize a fake PostgreSQL connection (using 'postgres7' as 'postgres' is remapped to it in AdoDB) FakeDbConnection::connect($GLOBALS['TYPO3_DB'], 'postgres7'); - $this->assertTrue($GLOBALS['TYPO3_DB']->handlerInstance['_DEFAULT']->isConnected()); + $this->assertTrue($GLOBALS['TYPO3_DB']->isConnected()); } /** Index: tests/db_oracle_testcase.php =================================================================== --- tests/db_oracle_testcase.php (revision 32189) +++ tests/db_oracle_testcase.php (working copy) @@ -64,10 +64,12 @@ $parserClassName = self::buildAccessibleProxy('ux_t3lib_sqlparser'); $GLOBALS['TYPO3_DB']->SQLparser = new $parserClassName; + $this->assertFalse($GLOBALS['TYPO3_DB']->isConnected()); + // Initialize a fake Oracle connection FakeDbConnection::connect($GLOBALS['TYPO3_DB'], 'oci8'); - $this->assertTrue($GLOBALS['TYPO3_DB']->handlerInstance['_DEFAULT']->isConnected()); + $this->assertTrue($GLOBALS['TYPO3_DB']->isConnected()); } /**