From 6a958bae47a35d1e4c49dfd37d93b87657ebf690 Mon Sep 17 00:00:00 2001 From: romanb Date: Tue, 11 Dec 2007 15:46:27 +0000 Subject: [PATCH] Fixed #665. --- lib/Doctrine/Manager.php | 11 +++++++++++ lib/Doctrine/Query.php | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index b07a0c419..cf0a1c7b0 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -545,6 +545,17 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera } return $this->getCurrentConnection(); } + + /** + * hasConnectionForComponent + * + * @param string $componentName + * @return boolean + */ + public function hasConnectionForComponent($componentName = null) + { + return isset($this->_bound[$componentName]); + } /** * getTable diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index c46a02a96..b6b1626d4 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -1649,8 +1649,10 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria public function loadRoot($name, $componentAlias) { // get the connection for the component - $this->_conn = Doctrine_Manager::getInstance() - ->getConnectionForComponent($name); + $manager = Doctrine_Manager::getInstance(); + if ($manager->hasConnectionForComponent($name)) { + $this->_conn = $manager->getConnectionForComponent($name); + } $table = $this->_conn->getTable($name); $tableName = $table->getTableName(); @@ -1681,7 +1683,10 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria public function buildInheritanceJoinSql($name, $componentAlias) { // get the connection for the component - $this->_conn = Doctrine_Manager::getInstance()->getConnectionForComponent($name); + $manager = Doctrine_Manager::getInstance(); + if ($manager->hasConnectionForComponent($name)) { + $this->_conn = $manager->getConnectionForComponent($name); + } $table = $this->_conn->getTable($name); $tableName = $table->getTableName();