src/Query/Parser.php
public static function get(Scope $scope, $connection, $multiple, $return = false)
    {
        $from = $connection->db;
        if (strpos($from, '.') !== false) {
            $tmp = explode('.', $connection->db);
            $from = end($tmp);
        }

		if (!is_null($scope->listWordsField)) {
			if ($scope->listWordsField === '') {
				$from = 'LIST_WORDS(' . $from . ')';
			} else {
				$from = 'LIST_WORDS(' . $from . '.' . $scope->listWordsField . ')';
			}
		}

		if (!is_null($scope->alternativesField)) {
			if ($scope->alternativesField === '') {
				$from = 'ALTERNATIVES(' . $from . ')';
			} else {
				$from = 'ALTERNATIVES(' . $from . '.' . $scope->alternativesField . ')';
			}
		}

        $connection->query = $scope->prepend.'SELECT '.$scope->select.' FROM '.$from.' ';

		if (!is_null($scope->join)){
			$connection->query .= $scope->join.' ';
		}

        if ($scope->where!='') {
            $connection->query .= 'WHERE'.$scope->where;
        }
        if (count($scope->groupBy)) {
            $connection->query .= 'GROUP BY '.implode(", ", $scope->groupBy).' ';
        }
        if (count($scope->orderBy)) {
            $connection->query .= 'ORDER BY '.implode(", ", $scope->orderBy).' ';
        }
        $connection->query .= 'LIMIT '.$scope->offset.', '.$scope->limit;
        if ($return) {
            return $connection->query;
        }
        $connection->method = 'POST';
        $connection->action = '/_query';
        $connection->multiple = $multiple;
        $scope->resetSelf();
        return self::sendQuery($connection);
    }
public static function get(Scope $scope, $connection, $multiple, $return = false)
    {
        $from = $connection->db;
        if (strpos($from, '.') !== false) {
            $tmp = explode('.', $connection->db);
            $from = end($tmp);
        }

		if (!is_null($scope->listWordsField)) {
			if ($scope->listWordsField === '') {
				$from = 'LIST_WORDS(' . $from . ')';
			} else {
				$from = 'LIST_WORDS(' . $from . '.' . $scope->listWordsField . ')';
			}
		}

		if (!is_null($scope->alternativesField)) {
			if ($scope->alternativesField === '') {
				$from = 'ALTERNATIVES(' . $from . ')';
			} else {
				$from = 'ALTERNATIVES(' . $from . '.' . $scope->alternativesField . ')';
			}
		}

        $connection->query = $scope->prepend.'SELECT '.$scope->select.' FROM '.$from.' ';

		if (!is_null($scope->join)){
			$connection->query .= $scope->join.' ';
		}

        if ($scope->where!='') {
            $connection->query .= 'WHERE'.$scope->where;
        }
        if (count($scope->groupBy)) {
            $connection->query .= 'GROUP BY '.implode(", ", $scope->groupBy).' ';
        }
        if (count($scope->orderBy)) {
            $connection->query .= 'ORDER BY '.implode(", ", $scope->orderBy).' ';
        }
        $connection->query .= 'LIMIT '.$scope->offset.', '.$scope->limit;
        if ($return) {
            return $connection->query;
        }
        $connection->method = 'POST';
        $connection->action = '/_query';
        $connection->multiple = $multiple;
        $scope->resetSelf();
        return self::sendQuery($connection);
    }
Build query from scope. Passes to execute it.

@param  \stdClass  $scope
@param  \stdClass $connection
@param  bool $multiple
@return \Clusterpoint\Response\Batch