diff --git a/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php b/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php index bd32fcc05..381c6e6fd 100644 --- a/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php +++ b/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php @@ -87,6 +87,7 @@ abstract class AbstractCollectionPersister } $sql = $this->getDeleteSQL($coll); + $this->conn->executeUpdate($sql, $this->getDeleteSQLParameters($coll)); } @@ -157,6 +158,7 @@ abstract class AbstractCollectionPersister * Count the size of this persistent collection * * @param \Doctrine\ORM\PersistentCollection $coll + * * @return integer */ public function count(PersistentCollection $coll) @@ -170,6 +172,7 @@ abstract class AbstractCollectionPersister * @param \Doctrine\ORM\PersistentCollection $coll * @param integer $offset * @param integer $length + * * @return array */ public function slice(PersistentCollection $coll, $offset, $length = null) @@ -182,6 +185,7 @@ abstract class AbstractCollectionPersister * * @param \Doctrine\ORM\PersistentCollection $coll * @param mixed \Doctrine\ORM\PersistentCollection + * * @return boolean */ public function contains(PersistentCollection $coll, $element) @@ -194,6 +198,7 @@ abstract class AbstractCollectionPersister * * @param \Doctrine\ORM\PersistentCollection $coll * @param mixed $key + * * @return boolean */ public function containsKey(PersistentCollection $coll, $key) @@ -206,6 +211,7 @@ abstract class AbstractCollectionPersister * * @param \Doctrine\ORM\PersistentCollection $coll * @param object $element + * * @return mixed */ public function removeElement(PersistentCollection $coll, $element) @@ -217,6 +223,7 @@ abstract class AbstractCollectionPersister * Remove an element by key * * @param \Doctrine\ORM\PersistentCollection $coll + * * @param mixed $key */ public function removeKey(PersistentCollection $coll, $key) diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index 0bc4801fb..7376a33a3 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -302,6 +302,7 @@ class BasicEntityPersister protected function assignDefaultVersionValue($entity, $id) { $value = $this->fetchVersionValue($this->class, $id); + $this->class->setFieldValue($entity, $this->class->versionField, $value); } @@ -324,11 +325,9 @@ class BasicEntityPersister . ' FROM ' . $tableName . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?'; - $value = $this->conn->fetchColumn($sql, array_values((array)$id)); - $value = Type::getType($versionedClass->fieldMappings[$versionField]['type']) - ->convertToPHPValue($value, $this->platform); + $value = $this->conn->fetchColumn($sql, array_values((array) $id)); - return $value; + return Type::getType($versionedClass->fieldMappings[$versionField]['type'])->convertToPHPValue($value, $this->platform); } /** @@ -454,6 +453,7 @@ class BasicEntityPersister case Type::INTEGER: $set[] = $versionColumn . ' = ' . $versionColumn . ' + 1'; break; + case Type::DATETIME: $set[] = $versionColumn . ' = CURRENT_TIMESTAMP'; break; @@ -610,9 +610,8 @@ class BasicEntityPersister // The associated entity $newVal is not yet persisted, so we must // set $newVal = null, in order to insert a null value and schedule an // extra update on the UnitOfWork. - $uow->scheduleExtraUpdate($entity, array( - $field => array(null, $newVal) - )); + $uow->scheduleExtraUpdate($entity, array($field => array(null, $newVal))); + $newVal = null; } } @@ -918,8 +917,7 @@ class BasicEntityPersister $rsm->addIndexBy('r', $assoc['indexBy']); } - return $this->em->newHydrator(Query::HYDRATE_OBJECT) - ->hydrateAll($stmt, $rsm, $hints); + return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); } /** @@ -944,8 +942,7 @@ class BasicEntityPersister $rsm->addIndexBy('r', $assoc['indexBy']); } - return $this->em->newHydrator(Query::HYDRATE_OBJECT) - ->hydrateAll($stmt, $rsm, $hints); + return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); } /** @@ -1059,11 +1056,10 @@ class BasicEntityPersister switch ($lockMode) { case LockMode::PESSIMISTIC_READ: $lockSql = ' ' . $this->platform->getReadLockSql(); - break; + case LockMode::PESSIMISTIC_WRITE: $lockSql = ' ' . $this->platform->getWriteLockSql(); - break; } @@ -1082,13 +1078,14 @@ class BasicEntityPersister $from = ' FROM ' . $tableName . ' '. $tableAlias; $join = $this->selectJoinSql . $joinSql; $where = ($conditionSql ? ' WHERE ' . $conditionSql : ''); + $lock = $this->platform->appendLockHint($from, $lockMode); + $query = $select + . $lock + . $join + . $where + . $orderBySql; - return $this->platform->modifyLimitQuery($select - . $this->platform->appendLockHint($from, $lockMode) - . $join - . $where - . $orderBySql, $limit, $offset) - . $lockSql; + return $this->platform->modifyLimitQuery($query, $limit, $offset) . $lockSql; } /**