@param $criteria

@return EntityInterface
963548
public function findFirst($criteria = null)
    {
        $this->getQuery()->setLimit(1);
        
        $resultSet = $this->findBy($criteria);
        $resultSet->rewind();
        
        return $resultSet->valid() ? $resultSet->current() : null;
    }
514576
public function prepareCriteria($criteria)
    {
        if (is_null($criteria)) {
            $criteria = array();
        }

        if (array_key_exists('$id', $criteria)) {
            $criteria['id'] = $criteria['$id'];
            unset($criteria['$id']);
        }

        return $criteria ? : array();
    }
271592
public function matching(Criteria $criteria) {
		if(!$this->baseRepository instanceof Selectable) {
			throw new \LogicException('The base repository does not implement Selectable.');
		}
		return $this->baseRepository->matching($criteria);
	}
42104
protected function getSelectConditionCriteriaSQL(Criteria $criteria)
    {
        $expression = $criteria->getWhereExpression();

        if ($expression === null) {
            return '';
        }

        $visitor = new SqlExpressionVisitor($this, $this->class);

        return $visitor->dispatch($expression);
    }
910037
public function init(ModelCriteria $criteria)
    {
        $this->dbName = $criteria->getDbName();
        $this->setClass($criteria->getModelName());
        $this->setWith($criteria->getWith());
        $this->asColumns = $criteria->getAsColumns();
        $this->hasLimit = $criteria->getLimit() != 0;

        return $this;
    }
435836
public function countByCriteria(Criteria $criteria)
    {
        $qb = $this->createCriteriaQueryBuilder($criteria, 'm');

        $qb->select('COUNT(m.id)');

        return $qb->getQuery()->getSingleScalarResult();
    }
1165028
public function mergeCriteria(array $criteria)
    {
        $this->criteria = null === $this->criteria ? $criteria : array_merge($this->criteria, $criteria);

        return $this;
    }
127083
public function delete($criteria=NULL)
    {
        $where = !is_null($criteria)
            ? 'WHERE '.$criteria->toSql()
            : NULL
            ;

        return $this->_connection->execute(sprintf(
            'DELETE FROM %s %s',
            $this->_name->quoted(),
            $where
            ));
    }
283
public function find($criteria = array())
    {
        if (!is_array($criteria)) {
            $criteria = array(
                '$id' => $criteria,
            );
        }

        // wrap criteria as NObject instance to make sure it can be override by hooks
        $criteria = new NObject($criteria);

        $this->applyHook('searching', $criteria);
        $cursor = $this->connection->query($this, $criteria->toArray());
        $this->applyHook('searched', $cursor);

        return $cursor;
    }
365879
public function matching(Criteria $criteria)
    {
        $allEntities = $this->wrapped->findAll();
        $collection = new ArrayCollection($allEntities);

        return $collection->matching($criteria);
    }
1014215
public function find($criteria = null) {
		$criteria = $this->normalizeCriteria($criteria);
		$result   = $this->getTableModel()->find($criteria);
		
		if ($result->count() === 0) {
			return;
		}
		
		if ($this->getResultType() & self::RESULT_OBJECT) {
			$result->setHydrateMode(ResultsetSimple::HYDRATE_OBJECTS);
		} else {
			$result->setHydrateMode(ResultsetSimple::HYDRATE_ARRAYS);
		}
		
		return $this->createResultset($result);
	}
1212375
public function init(Criteria $criteria)
    {
        try {
            $db = Propel::getServiceContainer()->getAdapter($criteria->getDbName());
            $this->setAdapter($db);
        } catch (\Exception $e) {
            // we are only doing this to allow easier debugging, so
            // no need to throw up the exception, just make note of it.
            Propel::log("Could not get a AdapterInterface, sql may be wrong", Propel::LOG_ERR);
        }

        // init $this->realtable
        $realtable = $criteria->getTableForAlias($this->table);
        $this->realtable = $realtable ? $realtable : $this->table;
    }
179916
public function findOneBy(array $criteria, array $orderBy = [])
    {
        $persister = $this->em->getUnitOfWork()->getEntityPersister($this->entityName);

        return $persister->load($criteria, null, null, [], null, 1, $orderBy);
    }
478505
private function createIndexQuery(array $criteria)
    {
        $query = new IndexQuery();

        foreach($criteria as $key => $value)
        {
            $query->addAndTerm($key, $value);
        }

        return $query->getQuery();
    }
356473
public function query($criteria=null)
    {
        $query = new \Pheasant\Query\Query($this->_connection);
        $query->from($this->_name);

        if(!is_null($criteria))
            $query->where($criteria);

        return $query;
    }
1054022
public function find($criteria = null, $projection = null) {
        return new Cursor($this, $this->database->registerCriteriaFunction($criteria), $projection);
    }
329431
public function any(array $criteria) : self
    {
        $sql = [];
        $par = [];
        foreach ($criteria as $row) {
            if (isset($row[1])) {
                $temp = $this->filterSQL($row[0], $row[1] ?? null, $row[2] ?? false);
                $sql[] = $temp[0];
                $par = array_merge($par, $temp[1]);
            }
        }
        return $this->where('(' . implode(' OR ', $sql) . ')', $par);
    }