Skip to content

Commit c2aaed5

Browse files
author
jools
committed
Merge commit 'dae7247f5d54e5a430d92b0c0bea7f23a870b479' into HEAD
2 parents be38fbe + 8b267e8 commit c2aaed5

File tree

1 file changed

+7
-0
lines changed
  • manual/en-US/chapters/packages

1 file changed

+7
-0
lines changed

manual/en-US/chapters/packages/data.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ The magic `__get` method in the `JDataSet` class effectively works like a "get c
9898

9999
The magic `__set` method is similar and works like a "set column" method. It will set all a value for a property for all the objects in the list.
100100

101+
The `clear` method will clear all the objects in the data set.
102+
103+
The `keys` method will return all of the keys of the objects stored in the set. It works like the `array_keys` function does on an PHP array.
104+
101105
```php
102106
// Add a new element to the end of the list.
103107
$players[] => new JData(array('race' => 'Skaven', 'level' => 2));
@@ -113,6 +117,9 @@ $players->level = 4;
113117

114118
// Get the value of a property for all object and also the count (get the average level).
115119
$average = $players->level / count($players);
120+
121+
// Clear all the objects.
122+
$players->clear();
116123
```
117124

118125
`JDataSet` supports magic methods that operate on all the objects in the list. Calling an arbitrary method will iterate of the list of objects, checking if each object has a callable method of the name of the method that was invoked. In such a case, the return values are assembled in an array forming the return value of the method invoked on the `JDataSet` object. The keys of the original objects are maintained in the result array.

0 commit comments

Comments
 (0)