[2.0] Cosmetics.
This commit is contained in:
parent
311cff87d3
commit
0c8a35f731
@ -350,6 +350,7 @@ class ObjectHydrator extends AbstractHydrator
|
|||||||
$indexExists = isset($this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]]);
|
$indexExists = isset($this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]]);
|
||||||
$index = $indexExists ? $this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]] : false;
|
$index = $indexExists ? $this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]] : false;
|
||||||
$indexIsValid = $index !== false ? $this->isIndexKeyInUse($baseElement, $relationAlias, $index) : false;
|
$indexIsValid = $index !== false ? $this->isIndexKeyInUse($baseElement, $relationAlias, $index) : false;
|
||||||
|
|
||||||
if ( ! $indexExists || ! $indexIsValid) {
|
if ( ! $indexExists || ! $indexIsValid) {
|
||||||
$element = $this->getEntity($data, $dqlAlias);
|
$element = $this->getEntity($data, $dqlAlias);
|
||||||
|
|
||||||
@ -397,17 +398,13 @@ class ObjectHydrator extends AbstractHydrator
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( ! $this->_ce[$parentClass]->reflFields[$relationAlias]->getValue($baseElement)) {
|
if ( ! $this->_ce[$parentClass]->reflFields[$relationAlias]->getValue($baseElement)) {
|
||||||
if ( ! isset($nonemptyComponents[$dqlAlias])) {
|
if (isset($nonemptyComponents[$dqlAlias])) {
|
||||||
//$this->setRelatedElement($baseElement, $relationAlias, null);
|
|
||||||
} else {
|
|
||||||
$this->setRelatedElement($baseElement, $relationAlias, $this->getEntity($data, $dqlAlias));
|
$this->setRelatedElement($baseElement, $relationAlias, $this->getEntity($data, $dqlAlias));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$coll = $this->_ce[$parentClass]
|
$coll = $this->_ce[$parentClass]->reflFields[$relationAlias]->getValue($baseElement);
|
||||||
->reflFields[$relationAlias]
|
|
||||||
->getValue($baseElement);
|
|
||||||
|
|
||||||
if ($coll !== null) {
|
if ($coll !== null) {
|
||||||
$this->updateResultPointer($coll, $index, $dqlAlias);
|
$this->updateResultPointer($coll, $index, $dqlAlias);
|
||||||
|
@ -87,6 +87,9 @@ class StandardEntityPersister
|
|||||||
* Initializes a new instance of a class derived from AbstractEntityPersister
|
* Initializes a new instance of a class derived from AbstractEntityPersister
|
||||||
* that uses the given EntityManager and persists instances of the class described
|
* that uses the given EntityManager and persists instances of the class described
|
||||||
* by the given class metadata descriptor.
|
* by the given class metadata descriptor.
|
||||||
|
*
|
||||||
|
* @param EntityManager $em
|
||||||
|
* @param ClassMetadata $class
|
||||||
*/
|
*/
|
||||||
public function __construct(EntityManager $em, ClassMetadata $class)
|
public function __construct(EntityManager $em, ClassMetadata $class)
|
||||||
{
|
{
|
||||||
@ -346,7 +349,7 @@ class StandardEntityPersister
|
|||||||
foreach ($stmt->fetch(Connection::FETCH_ASSOC) as $column => $value) {
|
foreach ($stmt->fetch(Connection::FETCH_ASSOC) as $column => $value) {
|
||||||
$fieldName = $this->_class->fieldNames[$column];
|
$fieldName = $this->_class->fieldNames[$column];
|
||||||
$data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName))
|
$data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName))
|
||||||
->convertToPHPValue($value, $this->_platform);
|
->convertToPHPValue($value, $this->_platform);
|
||||||
}
|
}
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
@ -394,20 +397,19 @@ class StandardEntityPersister
|
|||||||
*
|
*
|
||||||
* @param array $criteria
|
* @param array $criteria
|
||||||
* @return string The SQL.
|
* @return string The SQL.
|
||||||
* @todo Quote identifier.
|
|
||||||
*/
|
*/
|
||||||
protected function _getSelectSingleEntitySql(array $criteria)
|
protected function _getSelectSingleEntitySql(array $criteria)
|
||||||
{
|
{
|
||||||
$columnList = '';
|
$columnList = '';
|
||||||
foreach ($this->_class->columnNames as $column) {
|
foreach ($this->_class->columnNames as $column) {
|
||||||
if ($columnList != '') $columnList .= ', ';
|
if ($columnList != '') $columnList .= ', ';
|
||||||
$columnList .= $column;
|
$columnList .= $this->_conn->quoteIdentifier($column);
|
||||||
}
|
}
|
||||||
|
|
||||||
$conditionSql = '';
|
$conditionSql = '';
|
||||||
foreach ($criteria as $field => $value) {
|
foreach ($criteria as $field => $value) {
|
||||||
if ($conditionSql != '') $conditionSql .= ' AND ';
|
if ($conditionSql != '') $conditionSql .= ' AND ';
|
||||||
$conditionSql .= $this->_class->columnNames[$field] . ' = ?';
|
$conditionSql .= $this->_conn->quoteIdentifier($this->_class->columnNames[$field]) . ' = ?';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName()
|
return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName()
|
||||||
|
@ -1355,6 +1355,10 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
foreach ($data as $field => $value) {
|
foreach ($data as $field => $value) {
|
||||||
if (isset($class->reflFields[$field])) {
|
if (isset($class->reflFields[$field])) {
|
||||||
$currentValue = $class->reflFields[$field]->getValue($entity);
|
$currentValue = $class->reflFields[$field]->getValue($entity);
|
||||||
|
// Only override the current value if:
|
||||||
|
// a) There was no original value yet (nothing in _originalEntityData)
|
||||||
|
// or
|
||||||
|
// b) The original value is the same as the current value (it was not changed).
|
||||||
if ( ! isset($this->_originalEntityData[$oid][$field]) ||
|
if ( ! isset($this->_originalEntityData[$oid][$field]) ||
|
||||||
$currentValue == $this->_originalEntityData[$oid][$field]) {
|
$currentValue == $this->_originalEntityData[$oid][$field]) {
|
||||||
$class->reflFields[$field]->setValue($entity, $value);
|
$class->reflFields[$field]->setValue($entity, $value);
|
||||||
@ -1469,7 +1473,9 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
public function size()
|
public function size()
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($this->_identityMap as $entitySet) $count += count($entitySet);
|
foreach ($this->_identityMap as $entitySet) {
|
||||||
|
$count += count($entitySet);
|
||||||
|
}
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
/**
|
/**
|
||||||
* Times for comparison:
|
* Times for comparison:
|
||||||
*
|
*
|
||||||
* [romanb: 10000 rows => 1.8 seconds]
|
* [romanb: 10000 rows => 1 second]
|
||||||
*
|
*
|
||||||
* MAXIMUM TIME: 3 seconds
|
* MAXIMUM TIME: 2 seconds
|
||||||
*/
|
*/
|
||||||
public function testSimpleQueryArrayHydrationPerformance()
|
public function testSimpleQueryArrayHydrationPerformance()
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
$stmt = new HydratorMockStatement($resultSet);
|
$stmt = new HydratorMockStatement($resultSet);
|
||||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em);
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em);
|
||||||
|
|
||||||
$this->setMaxRunningTime(3);
|
$this->setMaxRunningTime(2);
|
||||||
$s = microtime(true);
|
$s = microtime(true);
|
||||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||||
$e = microtime(true);
|
$e = microtime(true);
|
||||||
@ -78,9 +78,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
/**
|
/**
|
||||||
* Times for comparison:
|
* Times for comparison:
|
||||||
*
|
*
|
||||||
* [romanb: 10000 rows => 3.0 seconds]
|
* [romanb: 10000 rows => 1.4 seconds]
|
||||||
*
|
*
|
||||||
* MAXIMUM TIME: 4 seconds
|
* MAXIMUM TIME: 3 seconds
|
||||||
*/
|
*/
|
||||||
public function testMixedQueryFetchJoinArrayHydrationPerformance()
|
public function testMixedQueryFetchJoinArrayHydrationPerformance()
|
||||||
{
|
{
|
||||||
@ -142,7 +142,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
$stmt = new HydratorMockStatement($resultSet);
|
$stmt = new HydratorMockStatement($resultSet);
|
||||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em);
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em);
|
||||||
|
|
||||||
$this->setMaxRunningTime(4);
|
$this->setMaxRunningTime(3);
|
||||||
$s = microtime(true);
|
$s = microtime(true);
|
||||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||||
$e = microtime(true);
|
$e = microtime(true);
|
||||||
@ -150,9 +150,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [romanb: 10000 rows => 3.8 seconds]
|
* [romanb: 10000 rows => 1.5 seconds]
|
||||||
*
|
*
|
||||||
* MAXIMUM TIME: 5 seconds
|
* MAXIMUM TIME: 3 seconds
|
||||||
*/
|
*/
|
||||||
public function testSimpleQueryObjectHydrationPerformance()
|
public function testSimpleQueryObjectHydrationPerformance()
|
||||||
{
|
{
|
||||||
@ -198,7 +198,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
$stmt = new HydratorMockStatement($resultSet);
|
$stmt = new HydratorMockStatement($resultSet);
|
||||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
||||||
|
|
||||||
$this->setMaxRunningTime(5);
|
$this->setMaxRunningTime(3);
|
||||||
$s = microtime(true);
|
$s = microtime(true);
|
||||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||||
$e = microtime(true);
|
$e = microtime(true);
|
||||||
@ -206,9 +206,9 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [romanb: 2000 rows => 3.1 seconds]
|
* [romanb: 2000 rows => 1 second]
|
||||||
*
|
*
|
||||||
* MAXIMUM TIME: 4 seconds
|
* MAXIMUM TIME: 2 seconds
|
||||||
*/
|
*/
|
||||||
public function testMixedQueryFetchJoinObjectHydrationPerformance()
|
public function testMixedQueryFetchJoinObjectHydrationPerformance()
|
||||||
{
|
{
|
||||||
@ -270,7 +270,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
|
|||||||
$stmt = new HydratorMockStatement($resultSet);
|
$stmt = new HydratorMockStatement($resultSet);
|
||||||
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
||||||
|
|
||||||
$this->setMaxRunningTime(4);
|
$this->setMaxRunningTime(2);
|
||||||
$s = microtime(true);
|
$s = microtime(true);
|
||||||
$result = $hydrator->hydrateAll($stmt, $rsm);
|
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||||
$e = microtime(true);
|
$e = microtime(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user