src/Expression.php
protected function _consume($sql_code, $escape_mode = 'param')
    {
        if (!is_object($sql_code)) {
            switch ($escape_mode) {
                case 'param':
                    return $this->_param($sql_code);
                case 'escape':
                    return $this->_escape($sql_code);
                case 'soft-escape':
                    return $this->_escapeSoft($sql_code);
                case 'none':
                    return $sql_code;
            }

            throw new Exception([
                '$escape_mode value is incorrect',
                'escape_mode' => $escape_mode,
            ]);
        }

        // User may add Expressionable trait to any class, then pass it's objects
        if ($sql_code instanceof Expressionable) {
            $sql_code = $sql_code->getDSQLExpression($this);
        }

        if (!$sql_code instanceof self) {
            throw new Exception([
                'Only Expressions or Expressionable objects may be used in Expression',
                'object' => $sql_code,
            ]);
        }

        // at this point $sql_code is instance of Expression
        $sql_code->params = &$this->params;
        $sql_code->_paramBase = &$this->_paramBase;
        $ret = $sql_code->render();

        // Queries should be wrapped in parentheses in most cases
        if ($sql_code instanceof Query) {
            $ret = '('.$ret.')';
        }

        // unset is needed here because ->params=&$othervar->params=foo will also change $othervar.
        // if we unset() first, we’re safe.
        unset($sql_code->params);
        $sql_code->params = [];

        return $ret;
    }
protected function _consume($sql_code, $escape_mode = 'param')
    {
        if (!is_object($sql_code)) {
            switch ($escape_mode) {
                case 'param':
                    return $this->_param($sql_code);
                case 'escape':
                    return $this->_escape($sql_code);
                case 'soft-escape':
                    return $this->_escapeSoft($sql_code);
                case 'none':
                    return $sql_code;
            }

            throw new Exception([
                '$escape_mode value is incorrect',
                'escape_mode' => $escape_mode,
            ]);
        }

        // User may add Expressionable trait to any class, then pass it's objects
        if ($sql_code instanceof Expressionable) {
            $sql_code = $sql_code->getDSQLExpression($this);
        }

        if (!$sql_code instanceof self) {
            throw new Exception([
                'Only Expressions or Expressionable objects may be used in Expression',
                'object' => $sql_code,
            ]);
        }

        // at this point $sql_code is instance of Expression
        $sql_code->params = &$this->params;
        $sql_code->_paramBase = &$this->_paramBase;
        $ret = $sql_code->render();

        // Queries should be wrapped in parentheses in most cases
        if ($sql_code instanceof Query) {
            $ret = '('.$ret.')';
        }

        // unset is needed here because ->params=&$othervar->params=foo will also change $othervar.
        // if we unset() first, we’re safe.
        unset($sql_code->params);
        $sql_code->params = [];

        return $ret;
    }
Recursively renders sub-query or expression, combining parameters.

@param mixed  $sql_code    Expression
@param string $escape_mode Fall-back escaping mode - param|escape|none

@return string|array Quoted expression or array of param names