Load $pNb elements ordered by ID ASC.

@param int $pNb
@return CollectionAbstract
16679
public function loadFirst($pNb = 1)
    {
        return $this->load(array(
            DbInterface::FILTER_LIMIT => $pNb,
            DbInterface::FILTER_ORDER => array(ItemInterface::IDFIELD => Db::ORDER_ASC)
        ));
    }
391325
public function getBtnClass($btn = null) {
		$btnClass = $this->_getClassForElement($btn);
		if (!empty($btnClass)) {
			$result = $btnClass;
		} else {
			$result = $this->_getClassForElement('btn-default');
		}

		return $result;
	}
320939
public function load(string $columnName)
    {
        $this->columnsToLoad[$columnName] = $this->structure->getColumn($columnName);

        return $this;
    }
361640
public function loadCollectionItemsData(Collection $collection): array
    {
        $query = $this->getItemSelectQuery();
        $query->where(
            $query->expr()->eq('collection_id', ':collection_id')
        )
        ->setParameter('collection_id', $collection->id, Type::INTEGER);

        $this->applyStatusCondition($query, $collection->status);

        $query->addOrderBy('position', 'ASC');

        return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
    }
107016
public function loadMedia(string $collectionName)
    {
        $collection = $this->exists
            ? $this->media
            : collect($this->unAttachedMediaLibraryItems)->pluck('media');

        return $collection
            ->filter(function (Media $mediaItem) use ($collectionName) {
                if ($collectionName == '') {
                    return true;
                }

                return $mediaItem->collection_name === $collectionName;
            })
            ->sortBy('order_column')
            ->values();
    }
793182
public function loadCollection(PersistentCollectionInterface $collection)
    {
        $mapping = $collection->getMapping();
        switch ($mapping->association) {
            case PropertyMetadata::ASSOCIATION_TYPE_EMBED_MANY:
                $this->loadEmbedManyCollection($collection);
                break;

            case PropertyMetadata::ASSOCIATION_TYPE_REFERENCE_MANY:
                if ($mapping->repositoryMethod !== null) {
                    $this->loadReferenceManyWithRepositoryMethod($collection);
                } else {
                    if ($mapping->isOwningSide) {
                        $this->loadReferenceManyCollectionOwningSide($collection);
                    } else {
                        $this->loadReferenceManyCollectionInverseSide($collection);
                    }
                }
                break;
        }
    }
1174114
private function load()
    {
        if (null === $this->collection) {
            $this->collection = $this->transformer->getChildren($this->page);
        }
    }
739243
public function getOrdered($collection, $sort = null)
    {
        if (!$sort) {
            return $collection;
        }

        $unordered = [];
        foreach ($collection as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        foreach ($sort as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
860055
private static function _addCustomAttributes(Collection $collection)
    {
        if (self::$_customPaginationPresenter) {
            $collection->setPaginationPresenter(self::$_customPaginationPresenter);
        }
        if (self::$_customView) {
            $collection->view(self::$_customView);
        }
        if (self::$_customCustomView) {
            $collection->customView(self::$_customCustomView);
        }
        if (self::$_customPaginate) {
            $collection->paginate(self::$_customPaginate);
        }
        if (self::$_customPerPage) {
            $collection->perPage(self::$_customPerPage);
        }
        if (self::$_customPage) {
            $collection->page(self::$_customPage);
        }
        if (self::$_customFilter) {
            $collection->filter(self::$_customFilter);
        }
        if (self::$_rendererNamespace) {
            $collection->setRendererNamespace(self::$_rendererNamespace);
        }

        return $collection;
    }
595148
public function loadFromDb()
    {
        $this->getLogger()->debug('Reading relationships from DB.');
        $query = $this->getQueryFactory()->createSelectAllQuery($this->tableName);
        $res = $query->execute();
        $rels = array();
        foreach ($res->fetchAll(\PDO::FETCH_ASSOC) as $row) {
            $rels[$row['relationship_name']] = $row;
        }
        ksort($rels);

        return $rels;
    }
708160
public function getAssociations($pk, $assocTbl, $callback=null, $ordered=true)
  {
    $associations = [];
    
    if ( $this->realPkSelection($pk) ){
      if ( $this->load($pk) ){
        $fkParts = explode('_', $this->tbl_name);
        $fk = array_pop($fkParts);
        
        $query = $this->db->getQuery(true)
          ->select('*')
          ->from($this->tbl.'_'.$assocTbl)
          ->where('id_'.$fk.' = '.$pk);
        
        if ( $ordered ){
          if ( is_bool($ordered) ){
            $query->order('ordering ASC');
          }
          else {
            $query->order($ordered);
          }
        }
        
        $this->db->setQuery($query);
        
        $associations = $this->db->loadObjectList();
        
        if ( is_callable($callback) ){
          foreach($associations as $row){
            $callback($row, $this);
          }
        }
      }
    }
    
    $this->errors = [];
    return $associations;
  }
1091433
final public function load($id = null)
    {
        if ($id === null) {
            $id = $this->id();
        }
        $this->source()->loadItem($id, $this);
        return $this;
    }
65331
public function orderByAsc(string $columnName) : OneToManyRelationDefiner
    {
        $this->orderByColumnNameDirectionMap[$columnName] = Ordering::ASC;

        return $this;
    }
374137
private function loadReferenceManyWithRepositoryMethod(PersistentCollectionInterface $collection)
    {
        $iterator  = $this->createReferenceManyWithRepositoryMethodIterator($collection);
        $mapping   = $collection->getMapping();
        $documents = $iterator->toArray();
        foreach ($documents as $key => $obj) {
            if ($mapping->type === Type::MAP) {
                $collection->set($key, $obj);
            } else {
                $collection->add($obj);
            }
        }
    }
1246767
public function load($pArgs = array())
    {
        if (! is_array($pArgs)) {
            return $this->loadById($pArgs);
        }

        $select = new Select($this->_dbContainer);

        if (isset($pArgs[DbInterface::FILTER_ORDER])) {
            $select->addOrder($pArgs[DbInterface::FILTER_ORDER]);
        } else {
            $select->addOrder(array(
                $this->getIdField() => Db::ORDER_DESC
            ));
        }

        if (isset($pArgs[DbInterface::FILTER_CONDITIONS]) and  $pArgs[DbInterface::FILTER_CONDITIONS] instanceof Conditions) {
            $select->loadConditions($pArgs[DbInterface::FILTER_CONDITIONS]);
        }

        $select->findOne();
        if ($select->count()) {
            $fields = $select->fetchAll(true);
        } else {
            $fields = array();
        }

        $this->_fields     = $fields;
        $this->_origFields = $fields;

        $idField = $this->getIdField();
        if (isset($this->_fields[$idField])) {
            $this->setId($this->_fields[$idField]);
        }

        return $this;
    }
972567
protected function getCollectionsForChangingOrder(IHierarchicObject $branch = null)
    {

        $typeColumnName = $this
            ->getObjectTypeField()
            ->getColumnName();
        $parentField = $this->getParentField();

        /**
         * @var $selectBuilder ISelectBuilder
         */
        $selectBuilder = $this
            ->getMetadata()
            ->getCollectionDataSource()
            ->select($typeColumnName);
        $selectBuilder->groupBy($typeColumnName);

        if ($branch) {
            $selectBuilder
                ->where()
                ->expr($parentField->getColumnName(), '=', ':' . $parentField->getName())
                ->bindValue(':' . $parentField->getName(), $branch->getId(), $parentField->getDataType());
        } else {
            $selectBuilder
                ->where()
                ->expr($parentField->getColumnName(), 'IS', ':' . $parentField->getName())
                ->bindNull(':' . $parentField->getName());
        }

        $result = $selectBuilder->execute();

        $collections = [];

        while (null != ($row = $result->fetch())) {
            $typeInfo = $row[$typeColumnName];
            if (0 != ($pos = strpos($typeInfo, IObjectType::PATH_SEPARATOR))) {
                $collectionName = substr($typeInfo, 0, $pos);
                $collections[$collectionName] = $this
                    ->getCollectionManager()
                    ->getCollection($collectionName);
            }
        }

        if (count($collections)) {
            $collections[$this->getName()] = $this;
        }

        return $collections;
    }
1182472
public function map($cb)
    {
        $data = $this->storage;

        $new = [];

        foreach ($data as $key => $value) {
            $new[$key] = call_user_func_array($cb, [$value, $key]);
        }

        return new Collection($new);
    }