next() public method

Go to the next row of the current result
public next ( ) : Result | boolean
return Result | boolean The result object or false if there is no next row
Esempio n. 1
0
 /**
  * Loop over the Result until the item id is not matching anymore the requested item id.
  *
  * @param string $itemId  The item id for which the ids shall be retrieved.
  *
  * @param Result $allTags The database result from which the ids shall be extracted.
  *
  * @return array
  */
 protected function getExistingTags($itemId, $allTags)
 {
     $thisExisting = array();
     // Determine existing tags for this item.
     /** @noinspection PhpUndefinedFieldInspection */
     if ($allTags->item_id == $itemId) {
         /** @noinspection PhpUndefinedFieldInspection */
         $thisExisting[] = $allTags->value_id;
     }
     /** @noinspection PhpUndefinedFieldInspection */
     while ($allTags->next() && $allTags->item_id == $itemId) {
         /** @noinspection PhpUndefinedFieldInspection */
         $thisExisting[] = $allTags->value_id;
     }
     return $thisExisting;
 }
 /**
  * Convert the value ids to a result array.
  *
  * @param Result     $valueResult The database result.
  *
  * @param null|array $counter     The destination for the counter values.
  *
  * @return array
  */
 protected function convertValueIds($valueResult, &$counter = null)
 {
     $result = array();
     $aliases = array();
     $idColumn = $this->getIdColumn();
     $aliasColumn = $this->getAliasColumn();
     while ($valueResult->next()) {
         $valueId = $valueResult->{$idColumn};
         $aliases[$valueId] = $valueResult->{$aliasColumn};
         $result[] = $valueId;
     }
     if ($counter !== null && !empty($result)) {
         $objCount = $this->getDatabase()->prepare(sprintf('SELECT value_id, COUNT(value_id) as mm_count
                     FROM tl_metamodel_tag_relation
                     WHERE att_id=?
                     AND value_id IN (%s)
                     GROUP BY item_id', $this->parameterMask($result)))->execute(array_merge(array($this->get('id')), $result));
         /** @noinspection PhpUndefinedFieldInspection */
         $amount = $objCount->mm_count;
         /** @noinspection PhpUndefinedFieldInspection */
         $valueId = $objCount->value_id;
         $alias = $aliases[$valueId];
         $counter[$valueId] = $amount;
         $counter[$alias] = $amount;
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Create a new collection from a database result
  *
  * @param Result $objResult The database result object
  * @param string $strTable  The table name
  *
  * @return static The model collection
  */
 public static function createFromDbResult(Result $objResult, $strTable)
 {
     $arrModels = array();
     $strClass = \Model::getClassFromTable($strTable);
     while ($objResult->next()) {
         /** @var Model $strClass */
         $objModel = \Model\Registry::getInstance()->fetch($strTable, $objResult->{$strClass::getPk()});
         if ($objModel !== null) {
             $objModel->mergeRow($objResult->row());
             $arrModels[] = $objModel;
         } else {
             $arrModels[] = new $strClass($objResult);
         }
     }
     return new static($arrModels, $strTable);
 }