Load a list of records.

@param array $filters Filters to apply.
@param string $sort Field to sort by.
@param string $order Sort order.
@param int $skip Limitstart.
@param int $limit Number of rows to return.

@return \core\persistent[]
196563
public static function get_records($filters = array(), $sort = '', $order = 'ASC', $skip = 0, $limit = 0) {
        global $DB;

        $orderby = '';
        if (!empty($sort)) {
            $orderby = $sort . ' ' . $order;
        }

        $records = $DB->get_records(static::TABLE, $filters, $orderby, '*', $skip, $limit);
        $instances = array();

        foreach ($records as $record) {
            $newrecord = new static(0, $record);
            array_push($instances, $newrecord);
        }
        return $instances;
    }
35668
public function find(array $filter = [], array $orderBy = [], $limit = 0,
        $offset = 0, array $associate = []
    ) {
        try {

            $query = $this->query()
                ->select()
                ->associate($associate)
                ->setFilter($filter);

            foreach ($orderBy as $orderByRule) {
                $query->orderBy($orderByRule[0], $orderByRule[1]);
            }

            return $query->limit($limit)->offset($offset)->run($this->connection);
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }
    }
500263
public function withFilters(array $filters = null)
    {
        if ($filters) {
            foreach ($filters as $filter) {
                switch ($filter['type']) {
                    case 'select':
                        $this->select($filter['fields']);
                        break;
                    case 'andWhere':
                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orWhere':
                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'andHaving':
                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orHaving':
                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'addGroupBy':
                        $this->addGroupBy($filter['field']);
                        break;
                    case 'addOrderBy':
                        $this->addOrderBy($filter['field'], $filter['order']);
                        break;
                    case 'fkAddOrderBy':
                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
                        break;
                    case 'paginate':
                        if (isset($filter['page'])) {
                            $this->paginate($filter['limit'], $filter['page']);
                        } else {
                            $this->paginate($filter['limit']);
                        }
                        break;
                }
            }
        }

        return $this;
    }
1049743
protected function getQueryBuilder(array $filters = [], array $sorting = [])
    {
        $queryBuilder = $this->getBaseQueryBuilder();
        if (!empty($filters)) {
            $this->addFilters($queryBuilder, $filters);
        }

        if (empty($sorting)) {
            $this->addSorting($queryBuilder, $this->getDefaultSorting());
        } else {
            $this->addSorting($queryBuilder, $sorting);
        }

        return $queryBuilder;
    }
896280
public static function getOrders($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/orders' . $filter->toQuery(), 'Order');
    }
395316
public function getOrphanedPages($class = SiteTree::class, $filter = array(), $sort = null, $join = null, $limit = null)
    {
        // Alter condition
        $table = DataObject::getSchema()->tableName($class);
        if (empty($filter)) {
            $where = array();
        } elseif (is_array($filter)) {
            $where = $filter;
        } else {
            $where = array($filter);
        }
        $where[] = array("\"{$table}\".\"ParentID\" != ?" => 0);
        $where[] = '"Parents"."ID" IS NULL';

        $orphans = new ArrayList();
        foreach (array(Versioned::DRAFT, Versioned::LIVE) as $stage) {
            $table .= ($stage == Versioned::LIVE) ? '_Live' : '';
            $stageOrphans = Versioned::get_by_stage(
                $class,
                $stage,
                $where,
                $sort,
                null,
                $limit
            )->leftJoin($table, "\"$table\".\"ParentID\" = \"Parents\".\"ID\"", "Parents");
            $orphans->merge($stageOrphans);
        }

        $orphans->removeDuplicates();

        return $orphans;
    }
1006194
public function findAllWithPagination($filters, $limit, $offset, $resultInArray = FALSE)
    {
        $where = $this->getQueryFilter($filters);
        $query = $this->getEntityManager()->createQuery('SELECT m FROM FulgurioLightCMSBundle:Media m ' . $where . ' ORDER BY m.created_at DESC')->setMaxResults($limit)->setFirstResult($offset);
        if (!empty($filters))
        {
            foreach ($filters as $filterKey => $filterValue)
            {
                $query->setParameter($filterKey, $filterValue);
            }
        }
        if ($resultInArray)
        {
            return $query->getArrayResult();
        }
        return $query->getResult();
    }
70788
public function listing($filters)
	{
		$listing = $this->smalldb->createListing($filters);
		return [
			'items' => array_values($listing->fetchAll()),	// Order of object's properties not guaranteed in JS
			'processed_filters' => $listing->getProcessedFilters(),
		];
	}
310717
public function select(array $filter, array $sorting = [])
    {
        $this->filter = $filter;
        $this->sorting = $sorting;
        $this->prefetch = false;
        $this->items = null;

        return $this;
    }
144622
public function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null){
        $res = array();
            
        $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' .
            ' FROM `##maj_admintasks`';
        
        $args = array();
                
        if ($order_by) {
            $sql .= ' ORDER BY ';
            $i = 0;
            foreach ($order_by as $key => $value) {
                if ($i > 0) {
                    $sql .= ',';
                }
                
                switch ($value['dir']) {
                    case 'asc':
                        $sql .= $value['column'] . ' ASC ';
                        break;
                    case 'desc':
                        $sql .= $value['column'] . ' DESC ';
                        break;
                }
                $i++;
            }
        } else {
            $sql .= ' ORDER BY majat_name ASC';
        }
        
        if ($limit) {
            $sql .= ' LIMIT :limit OFFSET :offset';
            $args['limit']  = $limit;
            $args['offset'] = $start;
        }
            
        $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);

        foreach($data as $ga) {
            $task = $this->loadTaskFromRow($ga);
			if($task && (empty($search) || ($search && strpos($task->getTitle(), $search) !== false)))
			{
				$res[] = $task;
			}
        }
		
        return $res;
    }
740919
public function fetch($where, $order=array(), $skipNum=0, $fetchNum=-1) {
		$obj = $this->getConnection();
        if (empty($where)) {
            return array();
        }
        foreach ($where as $key => $value) {
            $obj->where($key, $value);
        }
		if (empty($order) == false) {
			foreach ($order as $key => $value) {
				$obj->orderBy($key, $value);
			}
		}
		$limits = array();
		if ($fetchNum > 0) {
			if ($skipNum >= 0) {
				array_push($limits, $skipNum);
			}
			array_push($limits, $fetchNum);
		}
		if (empty($limits)) {
		    return $obj->get($this->getDao()->getTableName());
        }

		return $obj->get($this->getDao()->getTableName(), $limits);
	}
688191
public function get( $first = TRUE, $orders = array(), $limits = array() ){
		$this->validateFocus();
		$data = array();
		$conditions	= $this->getConditionQuery( array(), TRUE, TRUE, FALSE );						//  render WHERE clause if needed, cursored, without functions
		$orders		= $this->getOrderCondition( $orders );
		$limits		= $this->getLimitCondition( $limits );
		$columns	= $this->getColumnEnumeration( $this->columns );								//  get enumeration of masked column names
		$query		= 'SELECT '.$columns.' FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limits;

		$resultSet	= $this->dbc->query( $query );
		if( !$resultSet )
			return $first ? NULL : array();
		$resultList	= $resultSet->fetchAll( $this->getFetchMode() );
		if( $first )
			return $resultList ? $resultList[0] : NULL;
		return $resultList;
	}
202103
public function sourceRecords($params, $sort, $limit)
    {
        if ($sort) {
            $parts = explode(' ', $sort);
            $field = $parts[0];
            $direction = $parts[1];
        }
        $filter = array(
            'Comments.ID:GreaterThan' => 0,
        );
        if (count($params) > 0 && isset($params['Title'])) {
            $filter['News.Title:PartialMatch'] = $params['Title'];
        }
        /** @var ArrayList|News[] $ret */
        $ret = News::get()->filter($filter);
        /** @var ArrayList $returnSet */
        $returnSet = ArrayList::create();
        if ($ret) {
            foreach ($ret as $record) {
                $record->Commentcount = $record->Comments()->count();
                $record->Spamcount = $record->Comments()->filter(array('AkismetMarked' => 1))->count();
                $record->Hiddencount = $record->Comments()->filter(array('AkismetMarked' => 0, 'Visible' => 0))->count();

                if (isset($params['Comment']) && $params['Comment'] == 'SPAMCOUNT' && $record->Spamcount > 0) {
                    $returnSet->push($record);
                } elseif (isset($params['Comment']) && $params['Comment'] == 'HIDDENCOUNT' && $record->Hiddencount > 0) {
                    $returnSet->push($record);
                } elseif ((isset($params['Comment']) && $params['Comment'] == '') || !isset($params['Comment'])) {
                    $returnSet->push($record);
                }
            }
        }

        return $returnSet;
    }
1131263
public function getLookupResults($type, $filter = '', $limit = 10)
    {
        return $this->getRepository()->getValueList($type, $filter, $limit);
    }
981126
private function getSearchResult(array $filters, $limit, $page, $pageSize, $locale, $webspaceKey)
    {
        $repository = $this->searchManager->getRepository($this->articleDocumentClass);
        $search = $this->createSearch($repository->createSearch(), $filters, $locale);
        if (!$search) {
            return new \ArrayIterator([]);
        }

        $this->addPagination($search, $pageSize, $page, $limit);

        if (array_key_exists('sortBy', $filters) && is_array($filters['sortBy'])) {
            $sortMethod = array_key_exists('sortMethod', $filters) ? $filters['sortMethod'] : 'asc';
            $this->appendSortBy($filters['sortBy'], $sortMethod, $search);
        }

        if ($webspaceKey) {
            $webspaceQuery = new BoolQuery();

            // check for mainWebspace
            $webspaceQuery->add(new TermQuery('main_webspace', $webspaceKey), BoolQuery::SHOULD);

            // check for additionalWebspaces
            $webspaceQuery->add(new TermQuery('additional_webspaces', $webspaceKey), BoolQuery::SHOULD);

            $search->addQuery($webspaceQuery);
        }

        return $repository->findDocuments($search);
    }
756296
public function getOrders($limit = 10)
    {
        if ($Member = Security::getCurrentUser()) {
            $Orders = $Member->Orders()->sort('TransactionDate', 'DESC');

            $list = new PaginatedList($Orders, Controller::curr()->getRequest());
            $list->setPageLength($limit);

            return $list;
        }

        return false;
    }
716724
public function getRecords($filter = '', $order = ['.id'], $page = 1, $count = null, $dataDimensions = null)
    {
        if ($dataDimensions == null) {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        if (!is_array($order))
        {
            $order = [$order];
        }

        if ($this->readConnection instanceof FilteringConnection) {
            $records = $this->readConnection->getRecords($this->getCurrentContentTypeName(), $dataDimensions, $filter,
                $page, $count, $order);
        } else {

            $records = $this->getAllRecords($dataDimensions);

            if ($filter != '') {
                $records = RecordsFilter::filterRecords($records, $filter);
            }

            $records = RecordsSorter::orderRecords($records, $order);

            if ($count != null) {
                $records = RecordsPager::sliceRecords($records, $page, $count);
            }
        }

        foreach ($records as $record) {
            $record->setRepository($this);
        }

        return $records;
    }