Exemplo n.º 1
0
 /**
  * Generate the WHERE clauses of the query
  *
  * @access private
  * @param One_Query_Condition_Container $whereClauses
  * @return string
  */
 private function whereClauses(One_Query_Condition_Container $whereClauses)
 {
     $conditions = $whereClauses->getConditions();
     if (count($conditions) == 0) {
         return NULL;
     } else {
         if (count($conditions) == 1) {
             if ($conditions[0] instanceof One_Query_Condition_Container) {
                 return $this->whereClauses($conditions[0]);
             } else {
                 return $this->clause($conditions[0]);
             }
         } else {
             $clause = '( ';
             $all = array();
             foreach ($conditions as $condition) {
                 if ($condition instanceof One_Query_Condition_Container) {
                     $all[] = $this->whereClauses($condition);
                 } else {
                     $newClause = $this->clause($condition);
                     if (!is_null($newClause)) {
                         $all[] = $newClause;
                     }
                 }
             }
             if (count($all) > 0) {
                 $clause .= implode(' ' . $whereClauses->getType() . ' ', $all);
                 $clause .= ' )';
             } else {
                 $clause = NULL;
             }
             return $clause;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Generate the WHERE clauses of the query
  *
  * @access protected
  * @param One_Query_Condition_Container $whereClauses
  * @return string
  */
 protected function whereClauses(One_Query_Condition_Container $whereClauses)
 {
     $conditions = $whereClauses->getConditions();
     if (count($conditions) == 0) {
         return null;
     } else {
         if (count($conditions) == 1) {
             if ($conditions[0] instanceof One_Query_Condition_Container) {
                 //				return $this->whereClauses($conditions[0]);
             } else {
                 return $this->clause($conditions[0]);
             }
         } else {
             $all = array();
             foreach ($conditions as $condition) {
                 if ($condition instanceof One_Query_Condition_Container) {
                     //					$all[] = $this->whereClauses($condition);
                 } else {
                     $newClause = $this->clause($condition);
                     if (!is_null($newClause)) {
                         $all[] = $newClause;
                     }
                 }
             }
             if (count($all) > 0) {
                 $clause = $all;
             } else {
                 $clause = NULL;
             }
             return $clause;
         }
     }
     return NULL;
 }