Iterator that walks through a moodle_recordset applying the provided function.
More...
|
| __construct (\moodle_recordset $recordset, callable $callback, $callbackextra=null) |
| Create a new iterator applying the callback to each record.
|
|
| __destruct () |
| Closes the recordset.
|
|
| close () |
| Closes the recordset.
|
|
| current () |
| Returns the current element after applying the callback.
|
|
| key () |
| Returns current record key.
|
|
| next () |
| Moves the internal pointer to the next record.
|
|
| rewind () |
| Rewind is not supported.
|
|
| valid () |
| Returns whether the current position is valid or not.
|
|
|
callable | $callback |
| The callback.
|
|
mixed null | $callbackextra |
| Extra param for the callback.
|
|
moodle_recordset | $recordset |
| The recordset.
|
|
Iterator that walks through a moodle_recordset applying the provided function.
The internal recordset can be closed using the close() function.
Note that consumers of this class are responsible of closing the recordset, although there are some implicit closes under some ciscumstances:
- Once all recordset records have been iterated
- The object is destroyed
- Since
- Moodle 2.9
- Copyright
- 2015 David Monllao
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __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 | $recordset | Recordset to iterate. |
callable | $callback | Apply this function to each record. If using a method, it should be public. |
mixed | $callbackextra | An 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
-
◆ close()
core\dml\recordset_walk::close |
( |
| ) |
|
Closes the recordset.
- Return values
-
◆ current()
core\dml\recordset_walk::current |
( |
| ) |
|
Returns the current element after applying the callback.
- Return values
-
mixed|bool | The returned value type will depend on the callback. |
◆ key()
core\dml\recordset_walk::key |
( |
| ) |
|
Returns current record key.
- Return values
-
◆ next()
core\dml\recordset_walk::next |
( |
| ) |
|
Moves the internal pointer to the next record.
- Return values
-
◆ rewind()
core\dml\recordset_walk::rewind |
( |
| ) |
|
Rewind is not supported.
- Return values
-
◆ 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
-
The documentation for this class was generated from the following file:
- lib/classes/dml/recordset_walk.php