@param $condition

@return ActiveRecord
@throws NotFoundHttpException
436302
protected function findOne($condition) {
		$condition = $this->alias->encode($condition);
		$model = $this->model->findOne($condition);
		if(empty($model)) {
			throw new NotFoundHttpException(__METHOD__ . ':' . __LINE__);
		}
		return $model;
	}
615078
public function where($condition) {
        if (is_array($condition)) {
            $this->condition = new ArrayCondition($condition);
        } elseif ($condition instanceof ConditionInterface) {
            $this->condition = $condition;
        } else {
            throw new InvalidSQLConditionException('无效的SQL条件');
        }

        $this->condition->setStatementContext($this->statementContext);

        return $this;
    }
168809
private function buildCondition($condition) 
    {
        $where = '';
        
        foreach($condition as $filter) {
            switch(count($filter)) {
                case 1:
                $where .= ' ' . $this->validateLogicalOperator(($filter[0])) . ' ';
                break;
                case 3:
                $where .= $this->quoteColumnName($filter[1]) .' '. $this->validateComparisonOperators($filter[0]) .' '. $this->handleThridParameter($filter[2]);
                break;
                case 4:
                $where .= $this->quoteColumnName($filter[1]) .' '. $this->validateComparisonOperators($filter[0]) .' '. $this->quoteValue($filter[2]) . ' AND ' . $this->quoteValue($filter[3]);
                break;
            }
        }
        
        return $where;
    }
1261578
public static function findOne(array $conditions = [])
    {
        $data = static::entity()->getDatabase()->findOne(static::$collection, $conditions);

        if (!$data) {
            return null;
        }

        $instance = new static;
        $data['__webiny_db__'] = true;
        $instance->populate($data);

        return static::entity()->add($instance);
    }
607333
public function any($condition)
    {
        $this->filter($condition);

        $tmp = new \stdClass();

        return $this->getFirst($tmp) !== $tmp;
    }
1083891
public function fetchSet($condition = array())
    {
        $query = self::getInstance($this, $condition);

        return $this->getRepository()->fetch($query, AnDomain::FETCH_ENTITY_SET);
    }
489004
public function addCondition(\Sulu\Bundle\ResourceBundle\Entity\Condition $conditions)
    {
        $this->conditions[] = $conditions;

        return $this;
    }
715488
public function orWhereRaw(string $condition): self
    {
        $this->condition->orWhere([new RawExp($condition)]);

        return $this;
    }
42210
private static function filterCondition($condition)
    {
        foreach($condition as $k => $v) {
            if (is_array($v)) {
                $condition[$k] = array_values($v);
                foreach($v as $vv) {
                    if (is_array($vv)) {
                        throw new InvalidArgumentException('Nested arrays are not allowed in condition for findAll() and findOne().');
                    }
                }
            }
        }
        return $condition;
    }
274005
public function orWhere(...$conditions) : self
    {
        $this->conditionalQueryBuilder->orWhere(
            ...$this->createConditionExpressions($conditions)
        );

        return $this;
    }
1261441
public function on($condition){
        JoinOnImpl::on($this->context, $condition);
        return new JoinRule($this->context);
    }
910803
public function where(string $condition = '', array $params = []) {
        if ($condition) {
            $this->sql .= " WHERE $condition ";
            $this->params = array_merge($this->params, $params);
        }
        return $this;
    }
817553
public function orWhere(string ...$condition) : self
    {
        $this->whereConditions = $this->addConditionToClause(
            $this->whereConditions, 'OR', ...$condition);

        return $this;
    }
598140
public function fetchRow($condition = array())
    {
        $query = self::getInstance($this, $condition);

        return $this->getRepository()->fetch($query, AnDomain::FETCH_ROW);
    }
1346529
public function where($key, $condition)
    {
        $this->conditions[$key] = self::$conditionRegex[$condition];
        return $this;
    }
1023166
public function one(string $condition = '', array $params = []) {
        $this->model->builder->select('*')
            ->from($this->model->tableName);
        if ($condition) {
            $this->model->builder->where($condition, $params);
        }
        $r = $this->model->builder->limit(1)
            ->query();
        if (!is_array($r) || 0 === count($r)) {
            return null;
        }
        return $this->model->setup($r[0]);
    }
1011526
public function where($conditions, $values=null) {
		if(!$conditions)
			return $this;
		if($values !== null)
			$this->where[] = [$conditions => $values];
		else
			$this->where[] = $conditions;

		return $this;
	}