User Tools

Site Tools


datarecordcollection_class

This is an old revision of the document!


DatarecordCollection class

The primary purpose of this class is to keep a number of Datarecords bundled together. In addition to convenience, this can also speed things up when using the reference-fields in the Datarecord class as information for all contained Datarecord objects can be queried at the same time.

Basic usage

Usually the DatarecordCollection is the result of using the Filter object, but it can be spawned on its own, passing a Datarecord or an array of Datarecords into the constructor, or adding it later using the add function.

$collection = new DatarecordCollection($user);
$collection->add($another_user);

A datarecord can only contain objects of the same type and will adapt to the first object it receives.

The datarecord can be sorted by a specific field using sort and data can be retrieved using the different get-functions, such as:

foreach ($collection->getAll() as $user) {
    echo $user->full_name;
}
 
foreach ($collection->getAllFullValues('full_name') as $value) {
   echo $value;
}
datarecordcollection_class.1570655164.txt.gz ยท Last modified: 2019/10/09 21:06 by sahl

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki