通过记录集循环两次

I'm developping a Moodle 2.9.1 pluggin and I need to loop through a small recordset twice on the same page.

I'm using

$rs = $DB->get_recordset_sql($sql, array());

to get the data from mysql.

I would need a function like mysql data_seek(0) to work on the recordset again but I cannot find anything related to this in the moodle API or forums.

If you know the data is not going to be excessively huge, then you can use get_records_sql() instead. This will return an array, indexed by the first field in the SELECT. You can then do what you want with this array (loop through it multiple times, split, pop, shift, etc).

Just loop twice through $rs ??

foreach ($rs as $data){
}
foreach ($rs as $data){
} 

Or to do it clean make a function loop_thorught and call it twice ?