Commit cc56542d authored by zYne's avatar zYne

--no commit message

--no commit message
parent a0a9df9b
...@@ -800,6 +800,10 @@ class Doctrine_Hydrate implements Serializable ...@@ -800,6 +800,10 @@ class Doctrine_Hydrate implements Serializable
$parse = true; $parse = true;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
// The following little cache solution ensures that field aliases are
// parsed only once. This increases speed on large result sets by an order
// of magnitude.
if ( ! isset($cache[$key])) { if ( ! isset($cache[$key])) {
$e = explode('__', $key); $e = explode('__', $key);
$cache[$key]['field'] = $field = strtolower(array_pop($e)); $cache[$key]['field'] = $field = strtolower(array_pop($e));
...@@ -872,21 +876,8 @@ class Doctrine_Hydrate implements Serializable ...@@ -872,21 +876,8 @@ class Doctrine_Hydrate implements Serializable
$coll =& $prev[$parent][$componentAlias]; $coll =& $prev[$parent][$componentAlias];
} }
if ($index !== false) { $this->_setLastElement($prev, $coll, $index, $alias);
$prev[$alias] =& $coll[$index];
} else {
// first check the count (we do not want to get the last element
// of an empty collection/array)
if (count($coll) > 0) {
// check the type
if (is_array($coll)) {
end($coll);
$prev[$alias] =& $coll[key($coll)];
} else {
$prev[$alias] = $coll->getLast();
}
}
}
$currData[$alias] = array(); $currData[$alias] = array();
$identifiable[$alias] = null; $identifiable[$alias] = null;
} }
...@@ -948,6 +939,28 @@ class Doctrine_Hydrate implements Serializable ...@@ -948,6 +939,28 @@ class Doctrine_Hydrate implements Serializable
$coll =& $prev[$parent][$componentAlias]; $coll =& $prev[$parent][$componentAlias];
} }
$this->_setLastElement($prev, $coll, $index, $alias);
$index = false;
$currData[$alias] = array();
unset($identifiable[$alias]);
}
$driver->flush();
$stmt->closeCursor();
return $array;
}
/**
* _setLastElement
*
* sets the last element of given data array / collection
* as previous element
*
* @param boolean|integer $index
* @return void
*/
public function _setLastElement(&$prev, &$coll, $index, $alias)
{
if ($index !== false) { if ($index !== false) {
$prev[$alias] =& $coll[$index]; $prev[$alias] =& $coll[$index];
} else { } else {
...@@ -962,15 +975,6 @@ class Doctrine_Hydrate implements Serializable ...@@ -962,15 +975,6 @@ class Doctrine_Hydrate implements Serializable
} }
} }
} }
$index = false;
$currData[$alias] = array();
unset($identifiable[$alias]);
}
$driver->flush();
$stmt->closeCursor();
return $array;
} }
/** /**
* @return string returns a string representation of this object * @return string returns a string representation of this object
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment