@param bool $checkIndex

@return Query

@throws ODMException
340001
private function makeQuery($checkIndex = true)
    {
        $this->projectDiscriminator();
        $this->addFilterCriteria();
        $this->addDiscriminatorCondition();

        if ($checkIndex && !$this->checkIndexIsEligible()) {
            throw ODMException::queryIndexRequiresKeyCondition();
        }

        $keyCondition = $this->getKeyCondition();
        $filter       = $this->getFilter($keyCondition);

        return new Query(
            $this->dm,
            $this->class,
            $this->getIndex(),
            $keyCondition->getExpression(),
            $filter->getExpression(),
            $this->expr->getTokenPathMap(),
            $this->expr->getTokenValueMap(),
            $this->expr->projection->getExpression(),
            $this->primers
        );
    }
987189
public function getClientIp($checkProxy = true)
        {
            if ($checkProxy && $this->getServer('HTTP_CLIENT_IP') != null) {
                $ip = $this->getServer('HTTP_CLIENT_IP');
            } else if ($checkProxy && $this->getServer('HTTP_X_FORWARDED_FOR') != null) {
                $ip = $this->getServer('HTTP_X_FORWARDED_FOR');
            } else {
                $ip = $this->getServer('REMOTE_ADDR');
            }

            return $ip;
        }
417798
public function setChecked(bool $checked)
	{
		$this->value = $checked ? $this->getCheckedValue() : $this->getUncheckedValue();
		return $this;
	}
778392
public static function getInstance(string $checkClass) : CheckInterface
    {
        $checkClass = $checkClass;

        if (!class_exists($checkClass)) {
            throw new RuntimeException("Check class [$checkClass] does not exist");
        }

        if (!in_array(static::$interface, array_keys(class_implements($checkClass)))) {
            throw new RuntimeException("Check class [$checkClass] does not implement [" . static::$interface . "]");
        }

        return new $checkClass();
    }
953713
public function foreignKeyCheck ($check = true)
		{
			$check = intval(boolval($check));
			$this->db->createCommand("SET FOREIGN_KEY_CHECKS=$check")->execute();
		}
526518
public function getCreateIndexSQL(Index $index, $table)
    {
        return parent::getCreateIndexSQL($index, $table) . $this->getAdvancedIndexOptionsSQL($index);
    }
1066785
protected function byIndex($index, $select = true)
    {
        $elements = $this->getRelatedElements();
        if (!isset($elements[$index])) {
            throw new NoSuchElementException(sprintf('Cannot locate %s with index: %d', $this->type, $index));
        }

        $select ? $this->selectOption($elements[$index]) : $this->deselectOption($elements[$index]);
    }
300718
public function setChecked(bool $checked) : self
    {
        if ($checked) {
            $this->getField()->addProp('checked');
        } else {
            $this->getField()->removeProp('checked');
        }

        return $this;
    }
906477
public function create($checkExist = false)
    {
        $this->convertation();

        $model = new \CAgent;

        return $model->AddAgent(
            AgentHelper::createName($this->class, $this->constructorArgs, $this->callChain),
            $this->module,
            $this->periodically,
            $this->interval,
            null,
            $this->active,
            $this->executionTime,
            $this->sort,
            $this->userId,
            $checkExist
        );
    }
1263201
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
    {
        $entity = $this->mapper->newInstance();

        $relation = $this->getHasRelationQuery($relation, $entity);

        $query = $relation->getRelationCountQuery($relation->getRelatedMapper()->getQuery(), $this);

        if ($callback) {
            call_user_func($callback, $query);
        }

        return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
    }
347112
protected function getBoolQuery(Query $query): BoolQuery
    {
        $boolQuery = $query->getQuery();
        if (!$boolQuery instanceof BoolQuery) {
            throw new InvalidArgumentException(sprintf(
                'Localized query expander available only with %s, got: %s',
                BoolQuery::class,
                get_class($boolQuery)
            ));
        }

        return $boolQuery;
    }
1131292
public function searchRegex($searchRegex)
    {
        if (!is_bool($searchRegex) && $searchRegex !== 'false' && $searchRegex !== 'true') {
            throw new \InvalidArgumentException('$searchRegex needs to be a boolean');
        }
        $this->searchRegex = $searchRegex;
        return $this;
    }
909140
public function append($obj, $check = true)
    {
        if ( $check && $this->findIndexById( $obj->id ) >= 0) return $this;
        $this->elements[] = $obj;
        return $this;
    }
1141432
private function checkAuth($sourceEntityInstance, $checkInstance = null)
    {
        $check = $checkInstance instanceof Model ? $checkInstance
            : $checkInstance instanceof Relation ? $checkInstance
                : $sourceEntityInstance instanceof Model ? $sourceEntityInstance
                    : $sourceEntityInstance instanceof Relation ? $sourceEntityInstance
                        : null;
        if (!$this->getAuth()->canAuth(ActionVerb::READ(), get_class($sourceEntityInstance), $check)) {
            throw new ODataException('Access denied', 403);
        }
    }
1172535
public function setQueryClass($className)
    {
        if ($this->queryClass !== $className && !$this->isQueryOrScan()) {
            throw ODMException::queryOperationAlreadySet($this->queryClass);
        }

        $this->queryClass = $className;

        return $this;
    }
844419
public function server($index, $xss_clean = true)
    {
        if ($xss_clean) {
            return XssClean::getXssClean()->xss_clean($this->request->server[$index]??'');
        } else {
            return $this->request->server[$index]??'';
        }
    }
746894
private function emailCheck(CheckInterface $emailCheck, $checkMsg)
    {
        try {
            $emailCheck->performCheck();
            $this->logSuccessCheck($checkMsg, $emailCheck->getIndent(), self::CHECK_OK);
        } catch (Exception $exception) {
            $this->logFailCheck($checkMsg, $emailCheck->getIndent(), $exception->getMessage(), self::CHECK_FAIL);
            throw $exception;
        }
    }