Ejemplo n.º 1
0
 function testSelectWithPredicateFilters()
 {
     $query = new SQLQuery();
     $query->select(array("Name"))->from("SQLQueryTest_DO");
     $match = new ExactMatchFilter("Name", "Value");
     $match->setModel('SQLQueryTest_DO');
     $match->apply($query);
     $match = new PartialMatchFilter("Meta", "Value");
     $match->setModel('SQLQueryTest_DO');
     $match->apply($query);
     $this->assertEquals("SELECT Name FROM SQLQueryTest_DO WHERE (`SQLQueryTest_DO`.`Name` = 'Value') AND (`SQLQueryTest_DO`.`Meta` LIKE '%Value%')", $query->sql());
 }
 /**
  * @param DataQuery $query
  *
  * @return $this|DataQuery
  */
 public function apply(DataQuery $query)
 {
     $orGroup = $query->disjunctiveGroup();
     $orGroup = parent::apply($orGroup);
     if (count($this->subfilters) > 0) {
         foreach ($this->subfilters as $f) {
             $orGroup = $f->apply($orGroup);
         }
     }
     // The original query will have been affected by the things added to $orGroup above
     // but returning this instead of that will cause new filters to be added as AND
     return $query;
 }