Returns an array with the different query parts (statement type, fields,
parameters, joins, etc.).

@return array
324068
public function getQueryParts()
    {
        $result = [
            'type' => $this->getQueryType(),
            'fields' => $this->fields,
            'table' => $this->getTable()
        ];

        if (!empty($this->values)) {
            $result['values'] = $this->values;
        }

        if (!empty($this->set)) {
            $result['set'] = $this->set;
        }

        if (!empty($this->joins)) {
            $result['join'] = $this->joins;
        }

        if (!empty($this->wheres)) {
            $result['where'] = $this->wheres;
        }

        if (!empty($this->group)) {
            $result['group'] = $this->group;
        }

        if (!empty($this->order)) {
            $result['order'] = $this->order;
        }

        if (!empty($this->limit)) {
            $result['limit'] = $this->limit;
        }

        return $result;
    }
983954
public function getJoinedTables()
    {
        $joins = [];

        if (is_array($queryJoins = $this->query->getQuery()->joins)) {
            $joins = array_map(function ($join) {
                return $join->table;
            }, $queryJoins);
        }

        return $joins;
    }
111479
protected function getJoins()
    {
        $joins = [];
        $fields = array_merge($this->sortFields, $this->selectFields, $this->searchFields, $this->expressionFields);

        foreach ($fields as $field) {
            $joins = array_merge($joins, $field->getJoins());
        }

        return $joins;
    }
1056101
public static function internalAndWhere()
    {
        $query = [];
        
        foreach (static::fieldStateDescriber() as $field => $value) {
            $query[$field] = (is_array($value)) ? $value[1] : !$value;
        }
        
        return $query;
    }
625898
public function getQueryParameters() {
        $params = array();
        $params['userId'] = $this->user_id;
        $params['itemId'] = $this->item_id;
        if (isset($this->optional['sessionId']))
            $params['sessionId'] = $this->optional['sessionId'];
        return $params;
    }
1339381
public function getQueryParametersArray() {
        $queryString = $this->getQueryString();

        if (strlen($queryString) == 0) return array();

        $splitQuery = explode("&", substr($queryString, 1));
        $returnedParams = array();
        foreach ($splitQuery as $param) {
            $splitParam = explode("=", $param);
            if (sizeof($splitParam) == 2) $returnedParams [$splitParam [0]] = $splitParam [1];
        }

        return $returnedParams;

    }
324306
private function _buildQueryParams() {
		$query = [];

		$this->_where = is_array($this->_where) ? $this->_where : [];
		foreach ($this->_where as $key => $val) {
			$query[$key] = is_numeric($val) ? (int) $val : $val;
		}

		if(count($this->_select)) {
			$query[$this->selectFieldsKey] = implode(',', $this->_select);
		}
		if($this->_limit !== null) {
			$query[$this->limitKey] = $this->_limit;
		}
		if($this->_offset !== null) {
			$query[$this->offsetKey] = $this->_offset;
		}

		return $query;
	}
32543
protected function buildRelationQuery()
    {
        $args = func_get_args();

        list($relation, $args[0]) = explode('.', $this->column);

        return ['whereHas' => [$relation, function ($relation) use ($args) {
            call_user_func_array([$relation, $this->query], $args);
        }]];
    }
230501
protected function buildQuery()
    {
        $query = [
            'name' => $this->names,
            'country_id' => $this->country,
            'language_id' => $this->lang,
            'apikey' => $this->apikey
        ];

        return array_filter($query);
    }
812736
protected function getListQuery()
	{
		// Create a new query object.
		$db = $this->getDbo();
		$query = $db->getQuery(true);
		$user = JFactory::getUser();

		// Select the required fields from the table.
		$query->select(
			$this->getState(
				'list.select',
				'a.id, a.title, a.alias, a.note, a.published, a.access' .
				', a.checked_out, a.checked_out_time, a.created_user_id' .
				', a.path, a.parent_id, a.level, a.lft, a.rgt' .
				', a.language'
			)
		);
		$query->from('#__categories AS a');

		// Join over the language
		$query->select('l.title AS language_title, l.image AS language_image')
			->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');

		// Join over the users for the checked out user.
		$query->select('uc.name AS editor')
			->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');

		// Join over the asset groups.
		$query->select('ag.title AS access_level')
			->join('LEFT', '#__users_roles AS ag ON ag.id = a.access');

		// Join over the users for the author.
		$query->select('ua.name AS author_name')
			->join('LEFT', '#__users AS ua ON ua.id = a.created_user_id');

		// Join over the associations.
		$assoc = $this->getAssoc();

		if ($assoc)
		{
			$query->select('COUNT(asso2.id)>1 as association')
				->join('LEFT', '#__languages_associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_categories.item'))
				->join('LEFT', '#__languages_associations AS asso2 ON asso2.key = asso.key')
				->group('a.id, l.title, uc.name, ag.title, ua.name');
		}

		// Filter by extension
		if ($extension = $this->getState('filter.extension'))
		{
			$query->where('a.extension = ' . $db->quote($extension));
		}

		// Filter on the level.
		if ($level = $this->getState('filter.level'))
		{
			$query->where('a.level <= ' . (int) $level);
		}

		// Filter by access level.
		if ($access = $this->getState('filter.access'))
		{
			$query->where('a.access = ' . (int) $access);
		}

		// Implement View Level Access
		if (!$user->authorise('core.admin'))
		{
			$groups = implode(',', $user->getAuthorisedViewLevels());
			$query->where('a.access IN (' . $groups . ')');
		}

		// Filter by published state
		$published = $this->getState('filter.published');

		if (is_numeric($published))
		{
			$query->where('a.published = ' . (int) $published);
		}
		elseif ($published === '')
		{
			$query->where('(a.published IN (0, 1))');
		}

		// Filter by search in title
		$search = $this->getState('filter.search');

		if (!empty($search))
		{
			if (stripos($search, 'id:') === 0)
			{
				$query->where('a.id = ' . (int) substr($search, 3));
			}
			else
			{
				$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
				$query->where('(a.title LIKE ' . $search . ' OR a.alias LIKE ' . $search . ' OR a.note LIKE ' . $search . ')');
			}
		}

		// Filter on the language.
		if ($language = $this->getState('filter.language'))
		{
			$query->where('a.language = ' . $db->quote($language));
		}

		// Add the list ordering clause
		$listOrdering = $this->getState('list.ordering', 'a.lft');
		$listDirn = $db->escape($this->getState('list.direction', 'ASC'));

		if ($listOrdering == 'a.access')
		{
			$query->order('a.access ' . $listDirn . ', a.lft ' . $listDirn);
		}
		else
		{
			$query->order($db->escape($listOrdering) . ' ' . $listDirn);
		}

		// Group by on Categories for JOIN with component tables to count items
		$query->group('a.id,
				a.title,
				a.alias,
				a.note,
				a.published,
				a.access,
				a.checked_out,
				a.checked_out_time,
				a.created_user_id,
				a.path,
				a.parent_id,
				a.level,
				a.lft,
				a.rgt,
				a.language,
				l.title,
				l.image,
				uc.name,
				ag.title,
				ua.name'
		);

		return $query;
	}
597619
public function toArray()
    {
        $query = [
            'numericFilters' => '',
            'facetFilters'   => '',
        ];

        if ($this->query != '') {
            $query['query'] = $this->query;
        }

        if ($this->useLocationAwareSearch) {
            $query['aroundLatLng'] = $this->lat.','.$this->lng;
            $query['aroundRadius'] = $this->aroundRadius;
        }

        foreach ($this->dateRestrictions as $dateRestriction) {
            $query['numericFilters'] .= ','.
                $dateRestriction['dateFieldName'].
                $dateRestriction['operation'].
                $dateRestriction['date']->getTimeStamp();
        }

        foreach ($this->numericFilters as $filter) {
            $query['numericFilters'] .= ','.$filter;
        }

        foreach ($this->facets as $facet) {
            $query['facetFilters'] .= ','.$facet;
        }

        $query['page'] = $this->page;
        $query['hitsPerPage'] = $this->hitsPerPage;

        return $query;
    }
311691
public function getRows()
    {
        $rows = [];
        $wheres = $this->queryBuilder->wheres ?: [];

        foreach ($wheres as $where) {

            // Skip unsupported clauses
            if (!isset($where['column'])) {
                continue;
            }

            // If it doesn't contain the table name assume it's the "FROM" table
            if (strpos($where['column'], '.') === false) {
                $where['column'] = implode('.', [$this->queryBuilder->from, $where['column']]);
            }

            list($table, $column) = $this->splitTableAndColumn($where['column']);

            // Make sure that the where clause applies for the primary key column
            if ($column !== self::PRIMARY_KEY_COLUMN) {
                continue;
            }

            // Initialize a set for the current table
            if (!isset($rows[$table])) {
                $rows[$table] = [];
            }

            // Add the rows to the current table set
            if ($where['type'] === 'Basic') {
                if ($where['operator'] === '=' && is_numeric($where['value'])) {
                    $rows[$table][] = $where['value'];
                }
            }
            else if ($where['type'] === 'In') {
                $rows[$table] += $where['values'];
            }
        }

        return $rows;
    }
347253
public function getQueryTerms()
    {
        if ($this->_signs === null) {
            return $this->_terms;
        }

        $terms = array();

        foreach ($this->_signs as $id => $sign) {
            if ($sign !== false) {
                $terms[] = $this->_terms[$id];
            }
        }

        return $terms;
    }
707318
public function getSQLParamNames() : array
   {

      $out = [];

      foreach ( $this->_attributes as $attributeName => $attribute )
      {
         if ( Type::INIT_SQL === $attribute->getType() )
         {
            $out[] = $attributeName;
         }
      }

      return $out;

   }
104875
public function get(): array
    {
        $result = [];

        $filter = $this->jory->getFilter();
        if ($filter !== null) {
            $result[$this->keyRepository->get('flt')] = $this->getFilterArray($filter);
        }
        $sorts = $this->jory->getSorts();
        if (!empty($sorts)) {
            $result[$this->keyRepository->get('srt')] = $this->getSortsArray($sorts);
        }
        $relations = $this->jory->getRelations();
        if (!empty($relations)) {
            $result[$this->keyRepository->get('rlt')] = $this->getRelationsArray($relations);
        }
        if ($this->jory->getOffset() !== null) {
            $result[$this->keyRepository->get('ofs')] = $this->jory->getOffset();
        }
        if ($this->jory->getLimit() !== null) {
            $result[$this->keyRepository->get('lmt')] = $this->jory->getLimit();
        }
        if ($this->jory->getFields() !== null) {
            $result[$this->keyRepository->get('fld')] = $this->jory->getFields();
        }

        return $result;
    }
573397
public function query(): array
    {
        return [
            'charts'  => [
                [
                    'name'   => 'Some Data',
                    'values' => [25, 40, 30, 35, 8, 52, 17],
                ],
                [
                    'name'   => 'Another Set',
                    'values' => [25, 50, -10, 15, 18, 32, 27],
                ],
                [
                    'name'   => 'Yet Another',
                    'values' => [15, 20, -3, -15, 58, 12, -17],
                ],
                [
                    'name'   => 'And Last',
                    'values' => [10, 33, -8, -3, 70, 20, -34],
                ],
            ],
            'table'   => [
                new Repository(['product_id' => 'prod-100', 'name' => 'Desk', 'price' => 10.24, 'created_at' => '01.01.2020']),
                new Repository(['product_id' => 'prod-200', 'name' => 'Chair', 'price' => 65.9, 'created_at' => '01.01.2020']),
                new Repository(['product_id' => 'prod-300', 'name' => 'Computer', 'price' => 754.2, 'created_at' => '01.01.2020']),
                new Repository(['product_id' => 'prod-400', 'name' => 'Pen', 'price' => 0.1, 'created_at' => '01.01.2020']),
                new Repository(['product_id' => 'prod-400', 'name' => 'Brush', 'price' => 0.15, 'created_at' => '01.01.2020']),

            ],
            'metrics' => [
                ['keyValue' => number_format(6851, 0), 'keyDiff' => 10.08],
                ['keyValue' => number_format(24668, 0), 'keyDiff' => -30.76],
                ['keyValue' => number_format(65661, 2), 'keyDiff' => 3.84],
                ['keyValue' => number_format(10000, 0), 'keyDiff' => -169.54],
                ['keyValue' => number_format(1454887.12, 2), 'keyDiff' => 0.2],
            ],
            'place'   => [
                'lat' => 37.181244855427394,
                'lng' => -3.6021993309259415,
            ],
        ];
    }
768741
public function getQueryParameters(): array
    {
        $url = $this->getUrl();
        if (false === ($index = strpos($url, '?'))) {
            return [];
        }

        parse_str(substr($url, $index + 1), $queryParams);

        return $queryParams;
    }