Contao\Database\Result::next PHP Method

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
    public function next()
    {
        if ($this->blnDone) {
            return false;
        }
        if (($arrRow = $this->fetchAssoc()) !== false) {
            return $this;
        }
        $this->blnDone = true;
        return false;
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of Contao\Database\Result::next