PageFinder::postProcessQuery PHP Method

postProcessQuery() protected method

protected postProcessQuery ( $parentQuery )
    protected function postProcessQuery($parentQuery)
    {
        if (count($this->extraOrSelectors)) {
            // there were embedded OR selectors where one of them must match
            // i.e. id>0, field=(selector string), field=(selector string)
            // in the above example at least one 'field' must match
            // the 'field' portion is used only as a group name and isn't
            // actually used as part of the resulting query or than to know
            // what groups should be OR'd together
            $sqls = array();
            foreach ($this->extraOrSelectors as $groupName => $selectorGroup) {
                $n = 0;
                $sql = "\tpages.id IN (\n";
                foreach ($selectorGroup as $selectors) {
                    $pageFinder = new PageFinder();
                    $query = $pageFinder->find($selectors, array('returnQuery' => true, 'returnVerbose' => false, 'findAll' => true));
                    if ($n > 0) {
                        $sql .= " \n\tOR pages.id IN (\n";
                    }
                    $query->set('groupby', array());
                    $query->set('select', array('pages.id'));
                    $query->set('orderby', array());
                    // foreach($this->nativeWheres as $where) $query->where($where);  // doesn't seem to speed anything up, MySQL must already optimize for this
                    $sql .= tabIndent("\t\t" . $query->getQuery() . "\n)", 2);
                    $n++;
                }
                $sqls[] = $sql;
            }
            if (count($sqls)) {
                $sql = implode(" \n) AND (\n ", $sqls);
                $parentQuery->where("(\n{$sql}\n)");
            }
        }
        /* Possibly move existing subselectors to work like this rather than how they currently are
        		if(count($this->extraSubSelectors)) {
        			$sqls = array();
        			foreach($this->extraSubSelectors as $fieldName => $selectorGroup) {
        				$fieldName = $this->wire('database')->escapeCol($fieldName); 
        				$n = 0;
        				$sql = "\tpages.id IN (\n";
        				foreach($selectorGroup as $selectors) {
        					$pageFinder = new PageFinder();
        					$query = $pageFinder->find($selectors, array('returnQuery' => true, 'returnVerbose' => false));
        					if($n > 0) $sql .= " \n\tAND pages.id IN (\n";
        					$query->set('groupby', array());
        					$query->set('select', array('pages.id'));
        					$query->set('orderby', array());
        					// foreach($this->nativeWheres as $where) $query->where($where); 
        					$sql .= tabIndent("\t\t" . $query->getQuery() . "\n)", 2);
        					$n++;
        				}
        				$sqls[] = $sql;
        			}
        			if(count($sqls)) {
        				$sql = implode(" \n) AND (\n ", $sqls);
        				$parentQuery->where("(\n$sql\n)");
        			}
        		}
        		*/
    }