diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/lib/Doctrine/ORM/LazyCriteriaCollection.php index 28e2709ac..876341c72 100644 --- a/lib/Doctrine/ORM/LazyCriteriaCollection.php +++ b/lib/Doctrine/ORM/LazyCriteriaCollection.php @@ -82,6 +82,20 @@ class LazyCriteriaCollection extends AbstractLazyCollection implements Selectabl return $this->count = $this->entityPersister->count($this->criteria); } + /** + * check if collection is empty without loading it + * + * @return boolean TRUE if the collection is empty, FALSE otherwise. + */ + public function isEmpty() + { + if ($this->isInitialized()) { + return $this->collection->isEmpty(); + } + + return $this->count() == 0; + } + /** * Do an optimized search of an element *