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:
parent
b055d78ea1
commit
3e26330c53
@ -82,6 +82,20 @@ class LazyCriteriaCollection extends AbstractLazyCollection implements Selectabl
|
|||||||
return $this->count = $this->entityPersister->count($this->criteria);
|
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
|
* Do an optimized search of an element
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user