コード例 #1
0
ファイル: SearchMapper.php プロジェクト: bono-cms/Search
 /**
  * Appends query parts from registered mappers
  * 
  * @param \Krystal\Db\Sql\QueryBuilderInterface $db Query builder
  * @return void
  */
 private function appendFromMappers(QueryBuilderInterface $qb)
 {
     // Amount of registered mappers we have
     $amount = count($this->mappers);
     // Iteration counter
     $i = 0;
     foreach ($this->mappers as $mapper) {
         $qb->openBracket();
         $mapper->appendQuery($qb, self::PARAM_QUERY_PLACEHOLDER);
         $qb->closeBracket();
         ++$i;
         // Comparing iteration against number of mappers, tells whether this iteration is last
         $last = $i == $amount;
         // If we have more that one mapper, then we need to union results
         // And also, we should never append UNION in last iteration
         if ($amount > 1 && !$last) {
             $qb->union();
         }
     }
 }