public function getSql()
    {
        if ($this->isEmpty()) {
            throw new Exception("Invalid segment, please specify a valid segment.");
        }
        $sql = '';
        $subExpression = false;
        foreach ($this->tree as $expression) {
            $operator = $expression[self::INDEX_BOOL_OPERATOR];
            $operand = $expression[self::INDEX_OPERAND];

            if ($operator == self::BOOL_OPERATOR_OR
                && !$subExpression
            ) {
                $sql .= ' (';
                $subExpression = true;
            } else {
                $sql .= ' ';
            }

            $sql .= $operand;

            if ($operator == self::BOOL_OPERATOR_AND
                && $subExpression
            ) {
                $sql .= ')';
                $subExpression = false;
            }

            $sql .= " $operator";
        }
        if ($subExpression) {
            $sql .= ')';
        }
        return array(
            'where' => $sql,
            'bind'  => $this->valuesBind,
            'join'  => implode(' ', $this->joins)
        );
    }
public function getSql()
    {
        if ($this->isEmpty()) {
            throw new Exception("Invalid segment, please specify a valid segment.");
        }
        $sql = '';
        $subExpression = false;
        foreach ($this->tree as $expression) {
            $operator = $expression[self::INDEX_BOOL_OPERATOR];
            $operand = $expression[self::INDEX_OPERAND];

            if ($operator == self::BOOL_OPERATOR_OR
                && !$subExpression
            ) {
                $sql .= ' (';
                $subExpression = true;
            } else {
                $sql .= ' ';
            }

            $sql .= $operand;

            if ($operator == self::BOOL_OPERATOR_AND
                && $subExpression
            ) {
                $sql .= ')';
                $subExpression = false;
            }

            $sql .= " $operator";
        }
        if ($subExpression) {
            $sql .= ')';
        }
        return array(
            'where' => $sql,
            'bind'  => $this->valuesBind,
            'join'  => implode(' ', $this->joins)
        );
    }
public function getSql ( ) { if ( $ this -> isEmpty ( ) ) { throw new Exception ( "Invalid segment, please specify a valid segment." ) ; } $ sql = '' ; $ subExpression = false ; foreach ( $ this -> tree as $ expression ) { $ operator = $ expression [ self :: INDEX_BOOL_OPERATOR ] ; $ operand = $ expression [ self :: INDEX_OPERAND ] ; if ( $ operator == self :: BOOL_OPERATOR_OR && ! $ subExpression ) { $ sql .= ' (' ; $ subExpression = true ; } else { $ sql .= ' ' ; } $ sql .= $ operand ; if ( $ operator == self :: BOOL_OPERATOR_AND && $ subExpression ) { $ sql .= ')' ; $ subExpression = false ; } $ sql .= " $operator" ; } if ( $ subExpression ) { $ sql .= ')' ; } return array ( 'where' => $ sql , 'bind' => $ this -> valuesBind , 'join' => implode ( ' ' , $ this -> joins ) ) ; }
Given the array of parsed boolean logic, will return
an array containing the full SQL string representing the filter,
the needed joins and the values to bind to the query

@throws Exception
@return array SQL Query, Joins and Bind parameters
Given the array of parsed boolean logic will return an array containing the full SQL string representing the filter the needed joins and the values to bind to the query