diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 7de080484..906255241 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -871,6 +871,7 @@ final class PersistentCollection implements Collection, Selectable if ($this->association['type'] === ClassMetadata::MANY_TO_MANY) { $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association); + return new ArrayCollection($persister->loadCriteria($this, $criteria)); } diff --git a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php index db80abf53..9c84fe594 100644 --- a/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/ManyToManyPersister.php @@ -516,7 +516,7 @@ class ManyToManyPersister extends AbstractCollectionPersister } $sql = implode(' AND ', $filterClauses); - return $sql ? "(" . $sql . ")" : ""; + return $sql ? '(' . $sql . ')' : ''; } /** @@ -560,8 +560,7 @@ class ManyToManyPersister extends AbstractCollectionPersister $mapping = $coll->getMapping(); $owner = $coll->getOwner(); $ownerMetadata = $this->em->getClassMetadata(get_class($owner)); - - $whereClauses = $params = array(); + $whereClauses = $params = array(); foreach ($mapping['relationToSourceKeyColumns'] as $key => $value) { $whereClauses[] = sprintf('t.%s = ?', $key); @@ -572,7 +571,7 @@ class ManyToManyPersister extends AbstractCollectionPersister foreach ($parameters as $parameter) { list($name, $value) = $parameter; - $whereClauses[] = sprintf("te.%s = ?", $name); + $whereClauses[] = sprintf('te.%s = ?', $name); $params[] = $value; }