From 7f4abdf29218bfda5ea32d79fe70508c858e2206 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Tue, 14 Aug 2007 16:37:48 +0000 Subject: [PATCH] Added copy() method to Query.php and made NestedSet.php use it because native clone() does not work. Also Added ->getSql() to getRootAlias() so that _aliasMap is present after the parsing. --- lib/Doctrine/Hydrate.php | 2 ++ lib/Doctrine/Query.php | 15 ++++++++++++++- lib/Doctrine/Tree/NestedSet.php | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index 9041b3fb5..bab6161f1 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -179,6 +179,8 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable */ public function getRootAlias() { + $this->getSql(); + reset($this->_aliasMap); return key($this->_aliasMap); diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index 8a9b4a398..72ac67da8 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -1531,4 +1531,17 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable return $this->execute($params); } -} + + public function copy(Doctrine_Query $query = null) + { + if( !$query ) + { + $query = $this; + } + + $new = new Doctrine_Query(); + $new->_dqlParts = $query->_dqlParts; + + return $new; + } +} \ No newline at end of file diff --git a/lib/Doctrine/Tree/NestedSet.php b/lib/Doctrine/Tree/NestedSet.php index 8cd8356f2..b3131d331 100644 --- a/lib/Doctrine/Tree/NestedSet.php +++ b/lib/Doctrine/Tree/NestedSet.php @@ -269,7 +269,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int if (!isset($this->_baseQuery)) { $this->_baseQuery = $this->_createBaseQuery(); } - return clone $this->_baseQuery; + return $this->_baseQuery->copy(); } /**