src/main/php/DataDo/Data/Query/DefaultQueryBuilder.php
private function getFields($tokens, $namingConvention, $class)
    {
        $fields = [];
        $prefix = '';

        foreach ($tokens->getTokens() as $token) {
            if ($token instanceof ByToken) {
                return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention);
            }

            if ($token instanceof AllToken) {
                return $prefix . $this->fieldsToSQL([], $class, $namingConvention);
            }

            if($token instanceof DistinctToken) {
                $prefix .= 'DISTINCT ';
                continue;
            }

            if ($token instanceof AndToken) {
                // Ignore and tokens as they do nothing
                continue;
            }

            if (!($token instanceof ValueToken)) {
                throw new DslSyntaxException('Unexpected token ' . $token->getName() . ' in field selector', DATADO_UNEXPECTED_TOKEN);
            }

            $fields[] = lcfirst($token->getSource());
        }

        return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention);
    }
private function getFields($tokens, $namingConvention, $class)
    {
        $fields = [];
        $prefix = '';

        foreach ($tokens->getTokens() as $token) {
            if ($token instanceof ByToken) {
                return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention);
            }

            if ($token instanceof AllToken) {
                return $prefix . $this->fieldsToSQL([], $class, $namingConvention);
            }

            if($token instanceof DistinctToken) {
                $prefix .= 'DISTINCT ';
                continue;
            }

            if ($token instanceof AndToken) {
                // Ignore and tokens as they do nothing
                continue;
            }

            if (!($token instanceof ValueToken)) {
                throw new DslSyntaxException('Unexpected token ' . $token->getName() . ' in field selector', DATADO_UNEXPECTED_TOKEN);
            }

            $fields[] = lcfirst($token->getSource());
        }

        return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention);
    }
private function getFields ( $ tokens , $ namingConvention , $ class ) { $ fields = [ ] ; $ prefix = '' ; foreach ( $ tokens -> getTokens ( ) as $ token ) { if ( $ token instanceof ByToken ) { return $ prefix . $ this -> fieldsToSQL ( $ fields , $ class , $ namingConvention ) ; } if ( $ token instanceof AllToken ) { return $ prefix . $ this -> fieldsToSQL ( [ ] , $ class , $ namingConvention ) ; } if ( $ token instanceof DistinctToken ) { $ prefix .= 'DISTINCT ' ; continue ; } if ( $ token instanceof AndToken ) { // Ignore and tokens as they do nothing continue ; } if ( ! ( $ token instanceof ValueToken ) ) { throw new DslSyntaxException ( 'Unexpected token ' . $ token -> getName ( ) . ' in field selector' , DATADO_UNEXPECTED_TOKEN ) ; } $ fields [ ] = lcfirst ( $ token -> getSource ( ) ) ; } return $ prefix . $ this -> fieldsToSQL ( $ fields , $ class , $ namingConvention ) ; }
Build the SQL string for the fields from a MethodNameToken
@param MethodNameToken $tokens
@param NamingConvention $namingConvention
@param ReflectionClass $class
@return string
@throws DslSyntaxException if an unexpected token is found
Build the SQL string for the fields from a MethodNameToken