Doctrine\ODM\OrientDB\Repository::findBy PHP Method

findBy() public method

Optionally sorting and limiting details can be passed. An implementation may throw an UnexpectedValueException if certain values of the sorting or limiting details are not supported.
public findBy ( array $criteria, array $orderBy = [], integer | null $limit = null, integer | null $offset = null, $fetchPlan = '*:0' ) : mixed
$criteria array
$orderBy array
$limit integer | null
$offset integer | null
return mixed The objects.
    public function findBy(array $criteria, array $orderBy = array(), $limit = null, $offset = null, $fetchPlan = '*:0')
    {
        $results = array();
        foreach ($this->getOrientClasses() as $mappedClass) {
            $query = new Query(array($mappedClass));
            foreach ($criteria as $key => $value) {
                $query->andWhere("{$key} = ?", $value);
            }
            foreach ($orderBy as $key => $order) {
                $query->orderBy("{$key} {$order}");
            }
            if ($limit) {
                $query->limit($limit);
            }
            $collection = $this->getManager()->execute($query, $fetchPlan);
            if (!$collection instanceof ArrayCollection) {
                throw new Exception("Problems executing the query \"{$query->getRaw()}\". " . "The server returned {$collection} instead of ArrayCollection.");
            }
            $results = array_merge($results, $collection->toArray());
        }
        return new ArrayCollection($results);
    }