Issue Bug Closed

#62518Wrong result count

Natalia Postnikova 10/28/14, 14:47 updated 07/12/15, 13:43

Description

Code:

$result = $this->pageRepository->findByTagAndCategory($tag, $category);
if($result->count() > 0) {
    // always returns the number of pages total
}

If I echo the result count in my controller or in the view before processing the rows in a for-loop, the result count always returns the number of all entries in the db. The wrong result count can be “fixed” with a empty loop:

$result = $this->pageRepository->findByTagAndCategory($tag, $category);
foreach($result as $row) {
    // empty for loop to adjust counting
}
if($result->count() > 0) {
    // always return the number of total results
}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.