public function parse($filter, $aliases)
    {
        $result = '';
        /* Filter can be a single 'clause' or single 'group' */
        $clause = $filter->getClause();
        if (is_array($clause)) $clause = new \Praxigento\Core\Api\App\Web\Request\Conditions\Filter\Clause($clause);
        $group = $filter->getGroup();
        if (is_array($group)) $group = new \Praxigento\Core\Api\App\Web\Request\Conditions\Filter\Group($group);
        if ($clause) {
            /* there is single filtering clause in the filter */
            $attr = $clause->getAttr(); // required
            $func = $clause->getFunc(); // required
            /* one of them or nothing is allowed */
            $args = $clause->getArgs(); // is not used yet
            $value = $clause->getValue();
            /* compose clause */
            $valAttr = $this->mapAlias($attr, $aliases);
            $valLvalue = $this->dba->quote($value);
            $template = $this->parseFunc($func);
            $template = str_replace(self::PH_ATTR, $valAttr, $template);
            $template = str_replace(self::PH_VAL, $valLvalue, $template);
            $result = $template;
        } elseif ($group) {
            /* there is single group of the filtering clauses in the filter */
            $with = $group->getWith();
            $entries = $group->getEntries();
            /* collect group parts as SQL */
            $parts = [];
            /** @var \Praxigento\Core\Api\App\Web\Request\Conditions\Filter $entry */
            foreach ($entries as $entry) {
                /* place data into 'filter' container */
                if (is_array($entry)) $entry = new \Praxigento\Core\Api\App\Web\Request\Conditions\Filter($entry);
                $sql = $this->parse($entry, $aliases);
                $parts[] = $sql;
            }
            /* concatenate group parts using $with */
            foreach ($parts as $part) {
                if ($part) $result .= "($part) $with ";
            }
            /* cut the last $with */
            $tail = substr($result, -1 * (strlen($with) + 2));
            if ($tail == " $with ") {
                $result = substr($result, 0, strlen($result) - strlen($tail));
            }
        }
        return $result;
    }
public function parse($filter, $aliases)
    {
        $result = '';
        /* Filter can be a single 'clause' or single 'group' */
        $clause = $filter->getClause();
        if (is_array($clause)) $clause = new \Praxigento\Core\Api\App\Web\Request\Conditions\Filter\Clause($clause);
        $group = $filter->getGroup();
        if (is_array($group)) $group = new \Praxigento\Core\Api\App\Web\Request\Conditions\Filter\Group($group);
        if ($clause) {
            /* there is single filtering clause in the filter */
            $attr = $clause->getAttr(); // required
            $func = $clause->getFunc(); // required
            /* one of them or nothing is allowed */
            $args = $clause->getArgs(); // is not used yet
            $value = $clause->getValue();
            /* compose clause */
            $valAttr = $this->mapAlias($attr, $aliases);
            $valLvalue = $this->dba->quote($value);
            $template = $this->parseFunc($func);
            $template = str_replace(self::PH_ATTR, $valAttr, $template);
            $template = str_replace(self::PH_VAL, $valLvalue, $template);
            $result = $template;
        } elseif ($group) {
            /* there is single group of the filtering clauses in the filter */
            $with = $group->getWith();
            $entries = $group->getEntries();
            /* collect group parts as SQL */
            $parts = [];
            /** @var \Praxigento\Core\Api\App\Web\Request\Conditions\Filter $entry */
            foreach ($entries as $entry) {
                /* place data into 'filter' container */
                if (is_array($entry)) $entry = new \Praxigento\Core\Api\App\Web\Request\Conditions\Filter($entry);
                $sql = $this->parse($entry, $aliases);
                $parts[] = $sql;
            }
            /* concatenate group parts using $with */
            foreach ($parts as $part) {
                if ($part) $result .= "($part) $with ";
            }
            /* cut the last $with */
            $tail = substr($result, -1 * (strlen($with) + 2));
            if ($tail == " $with ") {
                $result = substr($result, 0, strlen($result) - strlen($tail));
            }
        }
        return $result;
    }
public function parse ( $ filter , $ aliases ) { $ result = '' ; /* Filter can be a single 'clause' or single 'group' */ $ clause = $ filter -> getClause ( ) ; if ( is_array ( $ clause ) ) $ clause = new \ Praxigento \ Core \ Api \ App \ Web \ Request \ Conditions \ Filter \ Clause ( $ clause ) ; $ group = $ filter -> getGroup ( ) ; if ( is_array ( $ group ) ) $ group = new \ Praxigento \ Core \ Api \ App \ Web \ Request \ Conditions \ Filter \ Group ( $ group ) ; if ( $ clause ) { /* there is single filtering clause in the filter */ $ attr = $ clause -> getAttr ( ) ; // required $ func = $ clause -> getFunc ( ) ; // required /* one of them or nothing is allowed */ $ args = $ clause -> getArgs ( ) ; // is not used yet $ value = $ clause -> getValue ( ) ; /* compose clause */ $ valAttr = $ this -> mapAlias ( $ attr , $ aliases ) ; $ valLvalue = $ this -> dba -> quote ( $ value ) ; $ template = $ this -> parseFunc ( $ func ) ; $ template = str_replace ( self :: PH_ATTR , $ valAttr , $ template ) ; $ template = str_replace ( self :: PH_VAL , $ valLvalue , $ template ) ; $ result = $ template ; } elseif ( $ group ) { /* there is single group of the filtering clauses in the filter */ $ with = $ group -> getWith ( ) ; $ entries = $ group -> getEntries ( ) ; /* collect group parts as SQL */ $ parts = [ ] ; /** @var \Praxigento\Core\Api\App\Web\Request\Conditions\Filter $entry */ foreach ( $ entries as $ entry ) { /* place data into 'filter' container */ if ( is_array ( $ entry ) ) $ entry = new \ Praxigento \ Core \ Api \ App \ Web \ Request \ Conditions \ Filter ( $ entry ) ; $ sql = $ this -> parse ( $ entry , $ aliases ) ; $ parts [ ] = $ sql ; } /* concatenate group parts using $with */ foreach ( $ parts as $ part ) { if ( $ part ) $ result .= "($part) $with " ; } /* cut the last $with */ $ tail = substr ( $ result , - 1 * ( strlen ( $ with ) + 2 ) ) ; if ( $ tail == " $with " ) { $ result = substr ( $ result , 0 , strlen ( $ result ) - strlen ( $ tail ) ) ; } } return $ result ; }
Parse tree-like filter structure and return string for SQL 'WHERE' clause.

@param \Praxigento\Core\Api\App\Web\Request\Conditions\Filter $filter
@param \Praxigento\Core\App\Web\Processor\WithQuery\Alias[] $aliases map of the aliases to [table, field]
@return string
@throws \Exception
Parse tree - like filter structure and return string for SQL WHERE clause .