views:

12

answers:

1

If you use something like each_hash to loop over a Mysql::Result set in Ruby when using the Mysql gem then you end up at the end of the result set and any subsequent each_hash loop doesn't have anything to loop over.

I see there is a Mysql::Result#row_seek method, which expects a Mysql::RowOffset object. But I'm unable to find any documentation for this.

A: 

Actually found that Mysql::Result#data_seek takes an integer that seems to do the trick, e.g.:

result.data_seek(0)
DEfusion