Пример #1
0
 /**
  * Combine results from 2 tables.
  *
  * Note: This will throw away some results
  *
  * @param ResultWrapper $res1
  * @param ResultWrapper $res2
  * @param int $limit
  * @param bool $ascending See note about $asc in $this->reallyDoQuery
  * @return FakeResultWrapper $res1 and $res2 combined
  */
 protected function combineResult($res1, $res2, $limit, $ascending)
 {
     $res1->rewind();
     $res2->rewind();
     $topRes1 = $res1->next();
     $topRes2 = $res2->next();
     $resultArray = array();
     for ($i = 0; $i < $limit && $topRes1 && $topRes2; $i++) {
         if (strcmp($topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField}) > 0) {
             if (!$ascending) {
                 $resultArray[] = $topRes1;
                 $topRes1 = $res1->next();
             } else {
                 $resultArray[] = $topRes2;
                 $topRes2 = $res2->next();
             }
         } else {
             if (!$ascending) {
                 $resultArray[] = $topRes2;
                 $topRes2 = $res2->next();
             } else {
                 $resultArray[] = $topRes1;
                 $topRes1 = $res1->next();
             }
         }
     }
     // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
     for (; $i < $limit && $topRes1; $i++) {
         // @codingStandardsIgnoreEnd
         $resultArray[] = $topRes1;
         $topRes1 = $res1->next();
     }
     // @codingStandardsIgnoreStart Squiz.WhiteSpace.SemicolonSpacing.Incorrect
     for (; $i < $limit && $topRes2; $i++) {
         // @codingStandardsIgnoreEnd
         $resultArray[] = $topRes2;
         $topRes2 = $res2->next();
     }
     return new FakeResultWrapper($resultArray);
 }
Пример #2
0
 /**
  * Move the iteration pointer to the next list item, and return it.
  * @return Revision
  */
 public function next()
 {
     $this->res->next();
     $this->initCurrent();
     return $this->current;
 }
Пример #3
0
 function next()
 {
     $row = $this->res->next();
     $this->setCurrent($row);
     $this->key++;
 }