Exemple #1
0
 protected function _sqlWhere()
 {
     if (!count($this->_where) && !count($this->_joined)) {
         return '';
     }
     $wheres = array();
     foreach ($this->_where as $condition) {
         list($field, $compare, $value) = $condition;
         if (!is_array($field)) {
             $wheres[] = $this->_sqlCondition($field, $compare, $value);
         } else {
             $conds = array();
             foreach ($field as $orCond) {
                 @(list($field, $compare, $value) = $orCond);
                 $conds[] = $this->_sqlCondition($field, $compare, $value);
             }
             Oops_Utils::ToNonEmptyArray($conds);
             $wheres[] = '(' . join(' OR ', $conds) . ')';
         }
     }
     foreach ($this->_joined as $joined) {
         list($selector, $fk, $jk, $joinType) = $joined;
         if ($joinType == self::JOIN_INNER) {
             $wheres[] = Oops_Sql_Common::escapeIdentifiers($this->_alias . '.' . $fk) . ' = ' . Oops_Sql_Common::escapeIdentifiers($selector->_alias . '.' . $jk);
         }
         $wheres[] = $selector->_sqlWhere();
     }
     Oops_Utils::ToNonEmptyArray($wheres);
     return join(' AND ', $wheres);
 }