src/xPDO/Om/xPDOQuery.php
public function buildConditionalClause($conditions, & $conjunction = xPDOQuery::SQL_AND, $isFirst = true) {
        $clause= '';
        if (is_array($conditions)) {
            $groups= count($conditions);
            $currentGroup= 1;
            $first = true;
            $origConjunction = $conjunction;
            $groupConjunction = $conjunction;
            foreach ($conditions as $groupKey => $group) {
                $groupClause = '';
                $groupClause.= $this->buildConditionalClause($group, $groupConjunction, $first);
                if ($first) {
                    $conjunction = $groupConjunction;
                }
                if (!empty($groupClause)) $clause.= $groupClause;
                $currentGroup++;
                $first = false;
            }
            $conjunction = $origConjunction;
            if ($groups > 1 && !empty($clause)) {
                $clause = " ( {$clause} ) ";
            }
            if (!$isFirst && !empty($clause)) {
                $clause = ' ' . $groupConjunction . ' ' . $clause;
            }
        } elseif (is_object($conditions) && $conditions instanceof xPDOQueryCondition) {
            if ($isFirst) {
                $conjunction = $conditions->conjunction;
            } else {
                $clause.= ' ' . $conditions->conjunction . ' ';
            }
            $clause.= $conditions->sql;
            if (!empty ($conditions->binding)) {
                $this->bindings[]= $conditions->binding;
            }
        }
        if ($this->xpdo->getDebug() === true) {
            $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Returning clause:\n{$clause}\nfrom conditions:\n" . print_r($conditions, 1));
        }
        return $clause;
    }
public function buildConditionalClause($conditions, & $conjunction = xPDOQuery::SQL_AND, $isFirst = true) {
        $clause= '';
        if (is_array($conditions)) {
            $groups= count($conditions);
            $currentGroup= 1;
            $first = true;
            $origConjunction = $conjunction;
            $groupConjunction = $conjunction;
            foreach ($conditions as $groupKey => $group) {
                $groupClause = '';
                $groupClause.= $this->buildConditionalClause($group, $groupConjunction, $first);
                if ($first) {
                    $conjunction = $groupConjunction;
                }
                if (!empty($groupClause)) $clause.= $groupClause;
                $currentGroup++;
                $first = false;
            }
            $conjunction = $origConjunction;
            if ($groups > 1 && !empty($clause)) {
                $clause = " ( {$clause} ) ";
            }
            if (!$isFirst && !empty($clause)) {
                $clause = ' ' . $groupConjunction . ' ' . $clause;
            }
        } elseif (is_object($conditions) && $conditions instanceof xPDOQueryCondition) {
            if ($isFirst) {
                $conjunction = $conditions->conjunction;
            } else {
                $clause.= ' ' . $conditions->conjunction . ' ';
            }
            $clause.= $conditions->sql;
            if (!empty ($conditions->binding)) {
                $this->bindings[]= $conditions->binding;
            }
        }
        if ($this->xpdo->getDebug() === true) {
            $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Returning clause:\n{$clause}\nfrom conditions:\n" . print_r($conditions, 1));
        }
        return $clause;
    }
public function buildConditionalClause ( $ conditions , & $ conjunction = xPDOQuery :: SQL_AND , $ isFirst = true ) { $ clause = '' ; if ( is_array ( $ conditions ) ) { $ groups = count ( $ conditions ) ; $ currentGroup = 1 ; $ first = true ; $ origConjunction = $ conjunction ; $ groupConjunction = $ conjunction ; foreach ( $ conditions as $ groupKey => $ group ) { $ groupClause = '' ; $ groupClause .= $ this -> buildConditionalClause ( $ group , $ groupConjunction , $ first ) ; if ( $ first ) { $ conjunction = $ groupConjunction ; } if ( ! empty ( $ groupClause ) ) $ clause .= $ groupClause ; $ currentGroup ++ ; $ first = false ; } $ conjunction = $ origConjunction ; if ( $ groups > 1 && ! empty ( $ clause ) ) { $ clause = " ( {$clause} ) " ; } if ( ! $ isFirst && ! empty ( $ clause ) ) { $ clause = ' ' . $ groupConjunction . ' ' . $ clause ; } } elseif ( is_object ( $ conditions ) && $ conditions instanceof xPDOQueryCondition ) { if ( $ isFirst ) { $ conjunction = $ conditions -> conjunction ; } else { $ clause .= ' ' . $ conditions -> conjunction . ' ' ; } $ clause .= $ conditions -> sql ; if ( ! empty ( $ conditions -> binding ) ) { $ this -> bindings [ ] = $ conditions -> binding ; } } if ( $ this -> xpdo -> getDebug ( ) === true ) { $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_DEBUG , "Returning clause:\n{$clause}\nfrom conditions:\n" . print_r ( $ conditions , 1 ) ) ; } return $ clause ; }
Builds conditional clauses from xPDO condition expressions.

@param array|xPDOQueryCondition $conditions An array of conditions or an xPDOQueryCondition instance.
@param string $conjunction Either xPDOQuery:SQL_AND or xPDOQuery::SQL_OR
@param boolean $isFirst Indicates if this is the first condition in an array.
@return string The generated SQL clause.
Builds conditional clauses from xPDO condition expressions .