Author: romanb
Date: 2008-09-13 21:06:49 +0100 (Sat, 13 Sep 2008)
New Revision: 4965

Modified:
   trunk/lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php
Log:
Some array/object related fixes to hydration

Modified: trunk/lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php
===================================================================
--- trunk/lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php      
2008-09-13 12:40:17 UTC (rev 4964)
+++ trunk/lib/Doctrine/ORM/Internal/Hydration/StandardHydrator.php      
2008-09-13 20:06:49 UTC (rev 4965)
@@ -150,7 +150,8 @@
             if (count($result) > 1 || count($result[0]) > 1) {
                 throw 
Doctrine_ORM_Exceptions_HydrationException::nonUniqueResult();
             }
-            return array_shift($this->_gatherScalarRowData($result[0], 
$cache)); 
+            $result = $this->_gatherScalarRowData($result[0], $cache);
+            return array_shift($result);
         }
         
         // Process result set
@@ -245,8 +246,13 @@
                                     $driver->getReferenceValue($baseElement, 
$relationAlias));
                         }
                     } else if ( ! isset($baseElement[$relationAlias])) {
-                        $driver->setRelatedElement($baseElement, 
$relationAlias,
-                                $driver->getElementCollection($entityName));
+                        if ($hydrationMode == Doctrine_Query::HYDRATE_ARRAY) {
+                            $array = array();
+                            $driver->setRelatedElement($baseElement, 
$relationAlias, $array);
+                        } else {
+                            $driver->setRelatedElement($baseElement, 
$relationAlias,
+                                    
$driver->getElementCollection($entityName));
+                        }
                     }
                 } else {
                     // x-1 relation
@@ -260,9 +266,16 @@
                                 $driver->getElement($data, $entityName));
                     }
                 }
-                if (($coll =& $driver->getReferenceValue($baseElement, 
$relationAlias)) !== null) {
-                    $this->_updateResultPointer($resultPointers, $coll, 
$index, $dqlAlias, $oneToOne);   
+                if ($hydrationMode == Doctrine_Query::HYDRATE_ARRAY) {
+                    if (($coll =& $driver->getReferenceValue($baseElement, 
$relationAlias)) !== null) {
+                        $this->_updateResultPointer($resultPointers, $coll, 
$index, $dqlAlias, $oneToOne);   
+                    }
+                } else {
+                    if (($coll = $driver->getReferenceValue($baseElement, 
$relationAlias)) !== null) {
+                        $this->_updateResultPointer($resultPointers, $coll, 
$index, $dqlAlias, $oneToOne);   
+                    }
                 }
+
             }
             
             // append scalar values to mixed result sets


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to