Find entities by a Module instance.

@param ModuleInterface|null $module
@param array|null           $orderBy
@param integer|null         $limit
@param integer|null         $offset

@return mixed
350974
public function findByModule(ModuleInterface $module = null, array $orderBy = null, $limit = null, $offset = null)
    {
        $criteria = [];

        if ($this->isModular($module)) {
            $criteria['module'] = $module;
        }

        /** @var EntityRepository $this */
        return $this->findBy($criteria, $orderBy, $limit, $offset);
    }
935646
public static function find(array $conditions = [], array $order = [], $limit = 0, $page = 0)
    {
        /**
         * Convert order parameters to Mongo format
         */
        $order = self::parseOrderParameters($order);
        $offset = $limit * ($page > 0 ? $page - 1 : 0);

        $data = self::entity()->getDatabase()->find(static::$collection, $conditions, $order, $limit, $offset);
        $parameters = [
            'conditions' => $conditions,
            'order'      => $order,
            'limit'      => $limit,
            'offset'     => $offset
        ];

        return new EntityCollection(get_called_class(), $data, $parameters);
    }
409304
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $criteria = array_merge($criteria, array("deleted" => false));

        return parent::findBy($criteria, $orderBy, $limit, $offset);
    }
30567
public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null)
    {
        $pool       = $this->manager->getPool();
        $manager_id = $this->class->getManagerIdentifier();

        $models = array();
        foreach ($this->class->getFieldManagerNames() as $manager) {
            $models[$manager] = $this->class->getFieldMapping($manager)->getName();
        }

        $data = $pool->getManager($manager_id)->getRepository($models[$manager_id])->findBy($criteria, $orderBy, $limit, $offset);

        if (empty($data)) {
            return array();
        }

        $builder = new ModelBuilder($this->manager, $this->uow, $this->class);

        return $builder->buildAll($data, $manager_id);
    }
802423
public function findBy(array $criteria, array $sorting = null, $limit = null, $offset = null)
    {
        $queryBuilder = $this->getCollectionQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);
        $this->applySorting($queryBuilder, (array) $sorting);

        if (null !== $limit) {
            $queryBuilder->setMaxResults($limit);
        }

        if (null !== $offset) {
            $queryBuilder->setFirstResult($offset);
        }

        $query = $queryBuilder->getQuery();

        if (null !== $limit) {
            return $this->collectionResult($query);
        }

        return $query->getResult();
    }
1235873
public function search_records(array $searchFields, array $requiredFields, $orderBy=null, $limit=null, $offset=null) {
		$data = array();
		if(is_array($searchFields) && is_array($requiredFields)) {
			$limitOffsetStr = '';
			if(is_numeric($limit) && $limit > 0) {
				$limitOffsetStr = ' LIMIT '. $limit;
				
				//using an offset without a limit seems silly...
				if(is_numeric($limitOffsetStr) && $offset > 0) {
					$limitOffsetStr .= ' OFFSET '. $offset;
				}
			}
			
			$filterStr = '';
			$required = '';
			$params = array();
			foreach($searchFields as $f=>$v) {
				$filterStr = ToolBox::create_list($filterStr, '(lower('. $f .') LIKE :'. $f .' OR :'. $f .' IS NULL)', ' AND ');
				$params[$f] = '%'. $v .'%';
			}
			foreach($requiredFields as $f=>$v) {
				$required = ToolBox::create_list($required, $f .'=:'. $f, ', ');
				$params[$f] = $v;
			}
			
			$sql = 'SELECT * FROM '. $this->tableName .' WHERE ('. $filterStr .') AND '. $required . $orderByStr . $limitOffsetStr;
			
			$orderByStr = ' ORDER BY '. $this->pkeyField;
			if(is_string($orderBy) && strlen($orderBy)) {
				$orderByStr = ' ORDER BY '. $orderBy;
			}
			
			try {
				$data = $this->dbObj->run_query($sql, $params);
			}
			catch(Exception $e) {
				throw new Exception(__METHOD__ .': error while performing search: '. $e->getMessage());
			}
		}
		else {
			throw new Exception(__METHOD__ .': missing searchFields or requiredFields');
		}
		
		return($data);
	}
759732
public function find(array $criteria = [], array $orderBy = null, $limit = null, $offset = null)
    {
        // @todo implement these
        if ($orderBy !== null || $limit !== null || $offset !== null) {
            throw new \Exception('orderBy, limit and offset not yet implemented');
        }

        if (empty($criteria)) {
            return $this->getConfigs();
        }

        return $this->search($criteria);
    }
907663
public function search(Search $entity, $limit, $offset, $sort_column, $sort_direction)
    {
        $selector = $this->selector
            ->create()
            ->addCountry($entity)
            ->addDateAdd($entity)
            ->addDateEnd($entity)
            ->addDatePremiere($entity)
            ->addGenres($entity)
            ->addLabels($entity)
            ->addName($entity)
            ->addStorage($entity)
            ->addStudio($entity)
            ->addType($entity)
            ->sort($sort_column, $sort_direction)
            ->limit($limit)
            ->offset($offset);

        return [
            'list' => $selector
                ->getQuerySelect()
                ->getQuery()
                ->getResult(),
            'total' => $selector
                ->getQueryTotal()
                ->getQuery()
                ->getSingleScalarResult(),
        ];
    }
993764
public function complexFindOneBy(array $criteria, array $orderBy = [])
    {
        $qb = $this->createQueryBuilder("p");

        foreach($criteria as $c => $v){
            $qb->andWhere("p.$c $v");
        }
        foreach($orderBy as $c => $v){
            $qb->addOrderBy("p.".$c,$v);
        }
        $qb->setMaxResults(1);
        return $qb->getQuery()->getResult()[0] ?? null;
    }
1320156
public function find( $table, $fields = null, $where = null, $order = null, $limit = null, $offset = null, $array = array (), $fetchMode = \PDO::FETCH_ASSOC )
     {
         // TODO: Implement find() method.
     }
791180
public function findAll($executeQuery = true, $orderedBy = 'id', $order = null)
    {
        if (!$executeQuery) {
            $dql = "
                SELECT u, pws, g, r, rws
                FROM Claroline\CoreBundle\Entity\User u
                LEFT JOIN u.personalWorkspace pws
                LEFT JOIN u.groups g
                LEFT JOIN u.roles r
                LEFT JOIN r.workspace rws
                WHERE u.isRemoved = false
                ORDER BY u.{$orderedBy} {$order}
            ";

            return $this->_em->createQuery($dql);
        }

        return parent::findAll();
    }
1062453
public function findBy(array $criteria = [], array $orders = [], $limit = null, $offset = null): array
    {
        $options = [];

        if ($orders) {
            foreach ($orders as $field => &$dir) {
                if ($dir === 'ASC') {
                    $dir = 1;
                } elseif ($dir === 'DESC') {
                    $dir = -1;
                }

            }
            $options['sort'] = $orders;
        }

        if ($limit !== null) {
            $options['limit'] = $limit;
        }

        if ($offset !== null) {
            $options['skip'] = $offset;
        }

        $options['projection'] = [];

        /** @var Cursor $cursor */
        $cursor = $this->collection->find($criteria, $options);

        $ids = [];

        $data = iterator_to_array($cursor);

        array_walk($data, function($value, $key) use (&$ids) {
            $ids[] = $value['_id'];
        });

        return $this->findByIds($ids);
    }
869852
public function findOneBy(array $criteria, ?array $orderBy = null)
    {
        $criteria = $this->mapCriteriaSetUuidsToStrings($criteria);
        $entity   = $this->entityRepository->findOneBy($criteria, $orderBy);
        if (null === $entity) {
            return null;
        }
        if ($entity instanceof EntityInterface) {
            $this->initialiseEntity($entity);

            return $entity;
        }
    }
457655
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $this->throwBadMethodException('findBy');
    }
836099
public function findBy(array $criteria, ?array $sorting = null, $limit = null, $offset = null)
    {
        $queryBuilder = $this->getCollectionQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);
        $this->applySorting($queryBuilder, $sorting);

        if (null !== $limit) {
            $queryBuilder->limit($limit);
        }

        if (null !== $offset) {
            $queryBuilder->skip($offset);
        }

        return $queryBuilder
            ->getQuery()
            ->getIterator()
        ;
    }
332377
public function findDeleted(array $orderBy = null, $limit = null, $offset = null)
    {
        /** @var \Doctrine\ORM\QueryBuilder $qb */
        $qb = $this->createQueryBuilder('e')
            ->where('e.deleted_at IS NOT NULL')
        ;

        $firstOrderBy = true;
        if (!empty($orderBy)) {
            foreach ($orderBy as $field => $value) {
                if ($firstOrderBy) {
                    $qb->orderBy("e.$field", $value);
                    $firstOrderBy = false;
                } else {
                    $qb->addOrderBy("e.$field", $value);
                }
            }
        }

        if (!empty($limit)) {
            $qb->setMaxResults($limit);
        }

        if (!empty($offset)) {
            $qb->setFirstResult($offset);
        }

        return $qb->getQuery()->getResult();
    }
1212951
public function getByOrder(string $orderBy, array $where = [], array $with = [], string $order = 'desc', int $limit = 0)
    {
        $query = $this->make($with);

        $query = $this->applyWhere($query, $where);

        $query = $query->orderBy($orderBy, $order);

        if ($limit) {
            $query = $query->take($limit);
        }

        return $query->get();
    }