We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Phalcon\Mvc\Model\Resultset offsetGet()


I'm using offsetGet() method to compare the current result to the next result in the Resultset. This works and I can comare what I need to, but the offsetGet() removes the result from the resultset. Is this the expected behaviour? If so is there a way to compare the current result with the next in such a way.


Hi dschissler,

Good shout, using the for as you say means I don't have to worry aboout the internal pointer. Working as I intended now.

Cheers Mark

It sounds like you are skipping over the next element by changing the internal pointer to the next element. Perhaps try a for loop to the resultset length instead of using a foreach. Then the internal pointer won't matter and you can play with the indexes directly. Also don't call offsetGet directly but use it as array access like $resultset[$i].