1
0
mirror of synced 2025-02-09 00:39:25 +03:00

check if collection is empty without loading it

Actually isEmpty() is always loading the collection in LazyCriteriaCollection.
A lazy version should use the existing functionality of count() to check if there are no elements if the collection is not initialized.
This commit is contained in:
Oliver Tischlinger 2015-09-23 17:34:11 +02:00
parent b055d78ea1
commit 3e26330c53

View File

@ -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
*