Calculates the list of associations that should get eager loaded
when fetching each record

@param \Cake\ORM\Query $query The query from where to derive the associations
@return void
320755
protected function _calculateAssociationMap($query)
    {
        $map = $query->getEagerLoader()->associationsMap($this->_defaultTable);
        $this->_matchingMap = (new Collection($map))
            ->match(['matching' => true])
            ->indexBy('alias')
            ->toArray();

        $this->_containMap = (new Collection(array_reverse($map)))
            ->match(['matching' => false])
            ->indexBy('nestKey')
            ->toArray();
    }
434699
public function executeRows(string $query): array
  {
    $result = $this->query($query);
    if ($this->haveFetchAll)
    {
      $ret = $result->fetch_all(MYSQLI_ASSOC);
    }
    else
    {
      $ret = [];
      while (($row = $result->fetch_assoc()))
      {
        $ret[] = $row;
      }
    }
    $result->free();

    if ($this->mysqli->more_results()) $this->mysqli->next_result();

    return $ret;
  }
159955
public function getRelationCountQuery(Query $query, Query $parent)
    {
        $query->select(new Expression('count(*)'));

        $key = $this->wrap($this->getQualifiedParentKeyName());

        return $query->where($this->getHasCompareKey(), '=', new Expression($key));
    }
1244120
private function setProperties($query)
    {
        foreach ($query as $property => $value) {
            if (property_exists(get_called_class(), $property)) {
                $this->$property = $value;
            }
        }
    }
538607
public function prepareExecuteAndFetchAll(Query $query)
    {
        $prepare = $this->prepareQuery($query);
        $execute = $this->executePrepared($prepare);

        return $this->fetchAllPrepared($prepare);
    }
1132990
private function applyJoins() : void
    {
        foreach ($this->getAssociations() as $association) {
            switch ($association->type()) {
                case Association::MANY_TO_ONE:
                    $this->query->leftJoinWith($association->getName());
                    break;

                case Association::ONE_TO_ONE:
                case Association::ONE_TO_MANY:
                case Association::MANY_TO_MANY:
                default:
                    break;
            }
        }
    }
727476
protected function load(QueryBuilder $query)
    {
        $metadata = $this->getClassMetadata();
        foreach ($metadata->getFieldMappings() as $field) {
            $fieldtype = $this->getFieldManager()->get($field['fieldtype'], $field);
            if ($fieldtype instanceof FieldTypeInterface) {
                $fieldtype->load($query, $metadata);
            }
        }
    }
453841
public function searchByQuery($query){
        if($query != null){
            $this->addParam("query", $query);
            $this->addParam("rank_token", $this->instagram->getUserRankToken());
        }
    }
1061792
public function is_related($query) {
        if (parent::is_related($query)) {
            return true;
        }
        if (!$this->load_choices()) {
            return false;
        }
        foreach ($this->choices as $key=>$value) {
            if (strpos(core_text::strtolower($key), $query) !== false) {
                return true;
            }
            if (strpos(core_text::strtolower($value), $query) !== false) {
                return true;
            }
        }
        return false;
    }
996903
protected function setJoin(Builder $query = null)
    {
        $query = $query ?: $this->query;

        $foreignKey = $this->related->getTable().'.'.$this->related->getKeyName();

        $localKey = $this->parent->getTable().'.'.$this->secondKey;

        $query->join($this->parent->getTable(), $localKey, '=', $foreignKey);
    }
291184
public static function addRelationship($query, $relationship)
    {
        $property = $query->getRepository()->getDescription()->getProperty($relationship);

        switch (true) {
            case $property->isManyToOne() :
                return self::_parseManyToOne($query, $property);
            case $property->isManyToMany() :
                return self::_parseManyToMany($query, $property);
            case $property->isOneToMany() :
                return self::_parseOneToMany($query, $property);

        }
    }
1052491
protected function setJoin(Builder $query = null)
    {
        $query = $query ?: $this->query;

        $foreignKey = $this->related->getTable().'.'.$this->secondKey;

        $query->join($this->parent->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey);
    }
527978
public function mergeToQuery(Select $query)
    {
        foreach ($this->getSelect() as $key => $select) {
            $query->prependSelect([$key => $select]);
        }

        foreach ($this->getJoin() as $join) {
            $query->join($join, null, null, $this->getBinds('join'));
        }

        if ($groupBy = $this->getGroupBy()) {
            $query->groupBy($groupBy);
        }

        if (($having = $this->getHaving()) && $having->hasChildren()) {
            $query->having($having);
        }

        if ($orderBy = $this->getOrderBy()) {
            $query->orderBy($orderBy);
        }

        return $this;
    }
530366
public function log(LoggedQuery $query)
    {
        if (!empty($query->params)) {
            $query->query = $this->_interpolate($query);
        }
        $this->_log($query);
    }
182649
public function applyRelationFilters(string $relationName, string $alias, Builder $query)
    {
        foreach ($this->getRelationFilters($relationName) as $filter) {
            $filter->apply($query, $alias);
        }
    }
364387
public function logQuery(array $query)
    {
        $this->queries[] = $query;

        if ($this->logger) {
            $this->logger->info('MongoDB Query: '.json_encode($query));
        }
    }
71695
public static function _fetch_handler( &$query )
	{
		// because the model is an object we force the fetch
		// arguments to obj so that we can still make use of
		// the group by and forward key functions
		$query->fetch_arguments = array( 'obj' );

		// Run the query and assign the reults
		// here we force the fetch arguments to assoc 
		// without this step model::assign will fail
		return static::assign( $query->handler->fetch( $query->build(), $query->handler->builder()->parameters, array( 'assoc' ) ) );
	}