Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Protected Attributes | List of all members
core\dml\recordset_walk Class Reference
Inheritance diagram for core\dml\recordset_walk:

Public Member Functions

 __construct (\moodle_recordset $recordset, callable $callback, $callbackextra=null)
 Create a new iterator applying the callback to each record. More...
 
 __destruct ()
 Closes the recordset. More...
 
 close ()
 Closes the recordset. More...
 
 current ()
 Returns the current element after applying the callback. More...
 
 key ()
 Returns current record key. More...
 
 next ()
 Moves the internal pointer to the next record. More...
 
 rewind ()
 Rewind is not supported. More...
 
 valid ()
 Returns whether the current position is valid or not. More...
 

Protected Attributes

callable $callback
 The callback.
 
mixed null $callbackextra
 Extra param for the callback.
 
moodle_recordset $recordset
 The recordset.
 

Constructor & Destructor Documentation

◆ __construct()

core\dml\recordset_walk::__construct ( \moodle_recordset  $recordset,
callable  $callback,
  $callbackextra = null 
)

Create a new iterator applying the callback to each record.

Parameters
moodle_recordset$recordsetRecordset to iterate.
callable$callbackApply this function to each record. If using a method, it should be public.
mixed$callbackextraAn extra single parameter to pass to the callback. Use a container to pass multiple values.

◆ __destruct()

core\dml\recordset_walk::__destruct ( )

Closes the recordset.

Return values
void

Member Function Documentation

◆ close()

core\dml\recordset_walk::close ( )

Closes the recordset.

Return values
void

◆ current()

core\dml\recordset_walk::current ( )

Returns the current element after applying the callback.

Return values
mixed|boolThe returned value type will depend on the callback.

◆ key()

core\dml\recordset_walk::key ( )

Returns current record key.

Return values
int

◆ next()

core\dml\recordset_walk::next ( )

Moves the internal pointer to the next record.

Return values
void

◆ rewind()

core\dml\recordset_walk::rewind ( )

Rewind is not supported.

Return values
void

◆ valid()

core\dml\recordset_walk::valid ( )

Returns whether the current position is valid or not.

If we reached the end of the recordset we close as we don't allow rewinds. Doing do so we reduce the chance of unclosed recordsets.

Return values
bool

The documentation for this class was generated from the following file: