コード例 #1
0
ファイル: ASolrCriteria.php プロジェクト: hezhiwen/YiiSolr
 /**
  * Merges this criteria with another
  * @param ASolrCriteria $criteria the criteria to merge with
  * @return ASolrCriteria the merged criteria
  */
 public function mergeWith(ASolrCriteria $criteria)
 {
     foreach ($criteria->getParams() as $name => $value) {
         if ($value === null) {
             continue;
         }
         if ($name == "q" && ($query = $this->getQuery()) != "") {
             $value = "(" . $query . ") AND (" . $criteria->getQuery() . ")";
         }
         if (!is_array($value)) {
             $this->setParam($name, $value);
         } else {
             foreach ($value as $key => $val) {
                 $this->addParam($name, $val);
             }
         }
     }
     return $this;
 }
コード例 #2
0
ファイル: ASolrSearchable.php プロジェクト: hezhiwen/YiiSolr
 /**
  * Finds all active records that matches the given criteria using solr
  * @param ASolrCriteria $criteria the solr criteria to use for searching
  * @return CActiveRecord[] an array of results
  */
 public function findAllBySolr($criteria = null)
 {
     $c = new ASolrCriteria();
     $c->mergeWith($this->getSolrCriteria());
     if ($criteria !== null) {
         $c->mergeWith($criteria);
     }
     if ($c->getQuery() == "") {
         $c->setQuery("*:*");
     }
     return $this->populateFromSolr($this->getSolrDocument()->findAll($c), true);
 }