|
| __construct ($data=[]) |
|
| exchangeArray ($input) |
|
| toArray () |
|
| append ($newval) |
|
| offsetSet ($index, $newval) |
|
| offsetUnset ($index) |
|
| setFinder (Closure $finder) |
|
| getDeleted () |
|
| refresh () |
|
| findBy ($key, $values, $op='==') |
|
| findOneBy ($key, $values, $op='==') |
|
| each (Closure $func) |
|
| map (Closure $func) |
|
| filter (Closure $func=null, $limit=null) |
|
| pluck ($columns) |
|
| toGroupedArray ($group_by='id', $only_these_fields=null, Closure $group_func=null) |
|
| first () |
|
| last () |
|
| val ($key) |
|
| unsetBy ($key, $values, $op='==') |
|
| orderBy ($order, $sort_flags=SORT_LOCALE_STRING) |
|
| limit ($arg1, $arg2=null) |
|
| sendMessage ($method, $params=[]) |
|
| __call ($method, $params) |
|
| merge (SimpleCollection $a_collection) |
|
| __construct ($input=[], $flags=self::STD_PROP_LIST, $iteratorClass='ArrayIterator') |
|
| __isset ($key) |
|
| __set ($key, $value) |
|
| __unset ($key) |
|
| __get ($key) |
|
| append ($value) |
|
| asort () |
|
| count () |
|
| exchangeArray ($data) |
|
| getArrayCopy () |
|
| getFlags () |
|
| getIterator () |
|
| getIteratorClass () |
|
| ksort () |
|
| natcasesort () |
|
| natsort () |
|
| offsetExists ($key) |
|
| offsetGet ($key) |
|
| offsetSet ($key, $value) |
|
| offsetUnset ($key) |
|
| serialize () |
|
| setFlags ($flags) |
|
| setIteratorClass ($class) |
|
| uasort ($function) |
|
| uksort ($function) |
|
| unserialize ($data) |
|
◆ __construct()
__construct |
( |
|
$data = [] | ) |
|
Constructor
- Parameters
-
mixed | $data | array or closure to fill collection |
◆ __call()
__call |
( |
|
$method, |
|
|
|
$params |
|
) |
| |
magic version of sendMessage calls undefineds methods on all elements of the collection But beware of the dark side...
- Parameters
-
string | $method | methodname to call |
array | $params | parameters for methodcall |
- Returns
- array of all return values
◆ append()
- See also
- ArrayObject::append()
◆ arrayToArrayObject()
static arrayToArrayObject |
( |
|
$a | ) |
|
|
static |
converts arrays or objects to ArrayObject objects if ArrayAccess interface is not available
- Parameters
-
- Returns
- ArrayAccess
◆ createFromArray()
static createFromArray |
( |
Array |
$data | ) |
|
|
static |
creates a collection from an array of arrays all arrays should contain same keys, but is not enforced
- Parameters
-
array | $data | array containing assoc arrays |
- Returns
- SimpleCollection
◆ each()
apply given callback to all elements of collection
- Parameters
-
Closure | $func | the function to call |
- Returns
- int addition of return values
◆ exchangeArray()
◆ filter()
filter |
( |
Closure |
$func = null , |
|
|
|
$limit = null |
|
) |
| |
filter elements if given callback returns true
- Parameters
-
Closure | $func | the function to call |
integer | $limit | limit number of found records |
- Returns
- SimpleCollection containing filtered elements
◆ findBy()
findBy |
( |
|
$key, |
|
|
|
$values, |
|
|
|
$op = '==' |
|
) |
| |
returns a new collection containing all elements where given columns value matches given value(s) using passed operator pass array for multiple values
operators: == equal, like php === identical, like php !=,<> not equal, like php !== not identical, like php <,>,<=,>= less,greater,less or equal,greater or equal >< between without borders, needs two arguments >=<= between including borders, needs two arguments %= like string, transliterate to ascii,case insensitive *= contains string ^= begins with string $= ends with string ~= regex
- Parameters
-
string | $key | the column name |
mixed | $value | value to search for |
mixed | $op | operator to find |
- Returns
- SimpleCollection with found records
◆ findOneBy()
findOneBy |
( |
|
$key, |
|
|
|
$values, |
|
|
|
$op = '==' |
|
) |
| |
returns the first element where given column has given value(s) pass array for multiple values
- Parameters
-
string | $key | the column name |
mixed | $value | value to search for, |
mixed | $op | operator to find |
- Returns
- SimpleORMap found record
◆ first()
get the first element
- Returns
- Array first element or null
◆ getCompFunc()
static getCompFunc |
( |
|
$operator, |
|
|
|
$args |
|
) |
| |
|
static |
returns closure to compare a value against given arguments using given operator
- Parameters
-
string | $operator | |
mixed | $args | |
- Exceptions
-
- Returns
- Closure comparison function
◆ getDeleted()
◆ last()
get the last element
- Returns
- Array last element or null
◆ limit()
limit |
( |
|
$arg1, |
|
|
|
$arg2 = null |
|
) |
| |
returns a new collection contaning a sequence of original collection mimics the sql limit constrain: used with one parameter, the first x elements are extracted used with two parameters, the first parameter denotes the offset, the second the number of elements
- Parameters
-
integer | $arg1 | |
integer | $arg2 | |
- Returns
- SimpleCollection
◆ map()
apply given callback to all elements of collection and give back array of return values
- Parameters
-
Closure | $func | the function to call |
- Returns
- array
◆ merge()
merge in another collection, elements are appended
- Parameters
-
◆ offsetSet()
offsetSet |
( |
|
$index, |
|
|
|
$newval |
|
) |
| |
Sets the value at the specified index ensures the value has ArrayAccess
- See also
- ArrayObject::offsetSet()
◆ offsetUnset()
Unsets the value at the specified index value is moved to internal deleted collection
- See also
- ArrayObject::offsetUnset()
- Exceptions
-
◆ orderBy()
orderBy |
( |
|
$order, |
|
|
|
$sort_flags = SORT_LOCALE_STRING |
|
) |
| |
sorts the collection by columns of contained elements and returns it
works like sql order by: first param is a string containing combinations of column names and sort direction, separated by comma e.g. 'name asc, nummer desc ' sorts first by name ascending and then by nummer descending second param denotes the sort type (using PHP sort constants): SORT_LOCALE_STRING: compare items as strings, transliterate latin1 to ascii, case insensitiv, natural order for numbers SORT_NUMERIC: compare items as integers SORT_STRING: compare items as strings SORT_NATURAL: compare items as strings using "natural ordering" SORT_FLAG_CASE: can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
- Parameters
-
string | $order | columns to order by |
integer | $sort_flags | |
- Returns
- SimpleCollection the sorted collection
◆ pluck()
extract array of columns values pass array or space-delimited string for multiple columns
- Parameters
-
string | array | $columns | the column(s) to extract |
- Returns
- array of extracted values
◆ refresh()
reloads the elements of the collection by calling the finder function
- Returns
- number of records after refresh
◆ sendMessage()
sendMessage |
( |
|
$method, |
|
|
|
$params = [] |
|
) |
| |
calls the given method on all elements of the collection
- Parameters
-
string | $method | methodname to call |
array | $params | parameters for methodcall |
- Returns
- array of all return values
◆ setFinder()
setFinder |
( |
Closure |
$finder | ) |
|
sets the finder function
- Parameters
-
◆ toArray()
converts the object and all elements to plain arrays
- Returns
- array
◆ toGroupedArray()
toGroupedArray |
( |
|
$group_by = 'id' , |
|
|
|
$only_these_fields = null , |
|
|
Closure |
$group_func = null |
|
) |
| |
returns the collection as grouped array first param is the column to group by, it becomes the key in the resulting array, default is pk. Limit returned fields with second param The grouped entries can optoionally go through the given callback. If no callback is provided, only the first grouped entry is returned, suitable for grouping by unique column
- Parameters
-
string | $group_by | the column to group by, pk if ommitted |
mixed | $only_these_fields | limit returned fields |
Closure | $group_func | closure to aggregate grouped entries |
- Returns
- array assoc array
◆ translitLatin1()
static translitLatin1 |
( |
|
$text | ) |
|
|
static |
transliterates latin1 string to ascii
- Parameters
-
- Returns
- string
◆ unsetBy()
unsetBy |
( |
|
$key, |
|
|
|
$values, |
|
|
|
$op = '==' |
|
) |
| |
mark element(s) for deletion where given column has given value(s) element(s) are moved to internal deleted collection pass array for multiple values
operators: == equal, like php === identical, like php !=,<> not equal, like php !== not identical, like php <,>,<=,>= less,greater,less or equal,greater or equal >< between without borders, needs two arguments >=<= between including borders, needs two arguments %= like string, transliterate to ascii,case insensitive *= contains string ^= begins with string $= ends with string ~= regex
- Parameters
-
string | $key | |
mixed | $values | |
mixed | $op | operator to find elements |
- Returns
- number of unsetted elements
◆ val()
get the the value from given key from first element
- Returns
- mixed
◆ $deleted
◆ $finder
◆ $last_count
The documentation for this class was generated from the following file: