Exemplo n.º 1
0
 public function addTo(Gpf_SqlBuilder_WhereClause $whereClause)
 {
     switch ($this->operator->getCode()) {
         case 'L':
         case 'NL':
             $whereClause->add($this->code, $this->operator->getSqlCode(), '%' . $this->value . '%', 'AND', $this->operator->getDoQuote());
             break;
         case 'DP':
             $this->addDatePresetTo($whereClause);
             break;
         case 'IN':
             $this->addArrayConditionTo($whereClause);
             break;
         case 'NOT IN':
             $this->addArrayNegativeConditionTo($whereClause);
             break;
         case 'T>=':
         case 'T<=':
         case 'T<':
             $whereClause->add("HOUR(" . $this->code . ")", $this->operator->getSqlCode(), Gpf_Common_DateUtils::getServerHours($this->value), 'AND', $this->operator->getDoQuote());
             break;
         case 'D>':
         case 'D>=':
             $whereClause->add($this->code, $this->operator->getSqlCode(), Gpf_DbEngine_Database::getDateString($this->getServerTime(Gpf_Common_DateUtils::getTimestamp($this->addTimePartToDate($this->value, '00:00:00')))), 'AND', $this->operator->getDoQuote());
             break;
         case 'D<=':
         case 'D<':
             $whereClause->add($this->code, $this->operator->getSqlCode(), Gpf_DbEngine_Database::getDateString($this->getServerTime(Gpf_Common_DateUtils::getTimestamp($this->addTimePartToDate($this->value, '23:59:59')))), 'AND', $this->operator->getDoQuote());
             break;
         default:
             if ($this->value == 'NULL') {
                 // Handle null values in conditions
                 $whereClause->add($this->code, $this->operator->getSqlCode(), null, 'AND', true);
                 //$this->operator->getDoQuote());
             } else {
                 $whereClause->add($this->code, $this->operator->getSqlCode(), $this->value, 'AND', true);
                 //$this->operator->getDoQuote());
             }
             break;
     }
 }
Exemplo n.º 2
0
 private function addTimeFilter(Gpf_SqlBuilder_Filter $filter, Gpf_SqlBuilder_CompoundWhereCondition $timeFilterCompoundWhere, $firtsTimeFilter = null) {
     $logicOperator = 'AND';
     if (!is_null($firtsTimeFilter) && Gpf_Common_DateUtils::getServerHours($firtsTimeFilter->getValue()) > Gpf_Common_DateUtils::getServerHours($filter->getValue())) {
         $logicOperator = 'OR';
     }
     $operator = $filter->getRawOperator();
     $timeFilterCompoundWhere->add("HOUR(".$filter->getCode().")", $operator->getSqlCode(), Gpf_Common_DateUtils::getServerHours($filter->getValue()), $logicOperator, $operator->getDoQuote());
 }