getEnd() public method

Get end index
public getEnd ( ) : integer
return integer
Example #1
0
 /**
  * Get all foreign entities ordered by a sort column
  *
  * If you have applied a limit to the query but need to know the full size of the unfiltered set, you must set
  * $check_full_set_size to true to gather this information at the expense of a second database query.
  *
  * @param SortedQuery $query
  * @param bool        $check_full_set_size
  * @param bool        $use_cache
  * @return QueryResult
  */
 public function sortedQuery(SortedQuery $query, $check_full_set_size = false, $use_cache = true)
 {
     $metadata = $this->getMapper()->getEntityMetadata($query->getClassName());
     if ($query->getRelationshipName()) {
         // Entity relationship based query
         $reader = new Reader($metadata, $query->getEntity());
         $relationship = $metadata->getRelationshipByName($query->getRelationshipName());
         if (!$relationship) {
             throw new InvalidArgumentException('Relationship "' . $query->getRelationshipName() . '" does not exist');
         }
         // Important, else the QueryResult class will try to hydrate the wrong entity
         $query->setClassName($relationship->getTarget());
         $key = $this->getKeyScheme()->getSortIndexKey($relationship, $query->getSortBy(), $reader->getId());
     } else {
         // Table based query
         $key = $this->getKeyScheme()->getTableSortKey($metadata->getTableName(), $query->getSortBy());
     }
     $results = $this->getDriver()->getSortedIndex($key, $query->getDirection() == Direction::DESC(), $query->getStart(), $query->getEnd());
     if (!$query->getStart() && !$query->getEnd()) {
         $full_size = count($results);
     } elseif ($check_full_set_size) {
         $full_size = $this->getDriver()->getSortedIndexSize($key);
     } else {
         $full_size = null;
     }
     return new QueryResult($this->entity_manager, $query, $results, $full_size, $use_cache);
 }