Record::foreach - jcobban/Genealogy GitHub Wiki

foreach($record as $fieldname => $value)

Up: class Record

This class supports iterating over the contents of the contents of the object using foreach. This is primarily useful for debugging code and to support passing an instance of Record to method $template->setFields. It is recommended to use $record->dump('label') which generates an HTML table to the trace if debugging is enabled. Note that this iteration includes both the fields from the database record as well as temporary fields added by $record→set or $record[$fieldName] on the left hand side of an assignment. This functionality comes from the implementation of the interface Iterator. An additional reason for doing this is because the default implementation of foreach iterates over all of the non-private members of an object, which is not helpful. The interface Iterator consists of:

  • public current ( void ) : mixed
  • public key ( void ) : scalar
  • public next ( void ) : void
  • public rewind ( void ) : void
  • public valid ( void ) : bool

Next: $record[$name]