class ObjectCollection extends Collection
Class for iterating over a list of Propel objects
Methods
array |
getData()
Get the data in the collection |
from Collection |
setData(array $data)
Set the data in the collection |
from Collection | |
integer |
getPosition()
Gets the position of the internal pointer This position can be later used in seek() |
from Collection |
mixed |
getFirst()
Move the internal pointer to the beginning of the list And get the first element in the collection |
from Collection |
boolean |
isFirst()
Check whether the internal pointer is at the beginning of the list |
from Collection |
mixed |
getPrevious()
Move the internal pointer backward And get the previous element in the collection |
from Collection |
mixed |
getCurrent()
Get the current element in the collection |
from Collection |
mixed |
getNext()
Move the internal pointer forward And get the next element in the collection |
from Collection |
mixed |
getLast()
Move the internal pointer to the end of the list And get the last element in the collection |
from Collection |
boolean |
isLast()
Check whether the internal pointer is at the end of the list |
from Collection |
boolean |
isEmpty()
Check if the collection is empty |
from Collection |
boolean |
isOdd()
Check if the current index is an odd integer |
from Collection |
boolean |
isEven()
Check if the current index is an even integer |
from Collection |
mixed |
get(mixed $key)
Get an element from its key Alias for ArrayObject::offsetGet() |
from Collection |
mixed |
pop()
Pops an element off the end of the collection |
from Collection |
mixed |
shift()
Pops an element off the beginning of the collection |
from Collection |
integer |
prepend(mixed $value)
Prepend one or more elements to the beginning of the collection |
from Collection |
set(mixed $key, mixed $value)
Add an element to the collection with the given key Alias for ArrayObject::offsetSet() |
from Collection | |
mixed |
remove(mixed $key)
Removes a specified collection element Alias for ArrayObject::offsetUnset() |
from Collection |
array |
clear()
Clears the collection |
from Collection |
boolean |
contains(mixed $element)
Whether or not this collection contains a specified element |
|
mixed |
search(mixed $element)
Search an element in the collection |
|
Collection |
diff(Collection $collection)
Returns an array of objects present in the collection that are not presents in the given collection. |
from Collection |
string | serialize() | from Collection |
unserialize(string $data) | from Collection | |
ArrayIterator |
getIterator()
Overrides ArrayObject::getIterator() to save the iterator object for internal use e.g. |
from Collection |
ArrayIterator | getInternalIterator() | from Collection |
clearIterator()
Clear the internal Iterator. |
from Collection | |
setModel(string $model)
Set the model of the elements in the collection |
from Collection | |
string |
getModel()
Get the model of the elements in the collection |
from Collection |
string |
getFullyQualifiedModel()
Get the model of the elements in the collection |
from Collection |
getTableMapClass() | from Collection | |
setFormatter(AbstractFormatter $formatter) | from Collection | |
AbstractFormatter | getFormatter() | from Collection |
ConnectionInterface |
getWriteConnection()
Get a write connection object for the database containing the elements of the collection |
from Collection |
BaseObject |
importFrom(mixed $parser, string $data)
Populate the current collection from a string, using a given parser format <code> $coll = new ObjectCollection(); $coll->setModel('Book'); $coll->importFrom('JSON', '{{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}'); </code> |
from Collection |
string |
exportTo(mixed $parser, boolean $usePrefix = true, boolean $includeLazyLoadColumns = true)
Export the current collection to a string, using a given parser format <code> $books = BookQuery::create()->find(); echo $book->exportTo('JSON'); => {{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}'); </code> |
from Collection |
array|string |
__call(string $name, mixed $params)
Catches calls to undefined methods. |
from Collection |
string |
__toString()
Returns a string representation of the current collection. |
from Collection |
__clone()
Creates clones of the containing data. |
from Collection | |
Collection |
fromXML(string $data)
Populate the collection from an XML string |
from Collection |
Collection |
fromYAML(string $data)
Populate the collection from a YAML string |
from Collection |
Collection |
fromJSON(string $data)
Populate the collection from a JSON string |
from Collection |
Collection |
fromCSV(string $data)
Populate the collection from a CSV string |
from Collection |
string |
toXML(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to an XML string |
from Collection |
string |
toYAML(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to a YAML string |
from Collection |
string |
toJSON(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to a JSON string |
from Collection |
string |
toCSV(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to a CSV string |
from Collection |
save(ConnectionInterface $con = null)
Save all the elements in the collection |
||
delete(ConnectionInterface $con = null)
Delete all the elements in the collection |
||
array |
getPrimaryKeys(boolean $usePrefix = true)
Get an array of the primary keys of all the objects in the collection |
|
fromArray(array $arr)
Populates the collection from an array Each object is populated from an array and the result is stored Does not empty the collection before adding the data from the array |
||
array |
toArray(string $keyColumn = null, boolean $usePrefix = false, string $keyType = TableMap::TYPE_PHPNAME, boolean $includeLazyLoadColumns = true, array $alreadyDumpedObjects = array())
Get an array representation of the collection Each object is turned into an array and the result is returned |
|
array |
getArrayCopy(string $keyColumn = null, boolean $usePrefix = false)
Get an array representation of the collection |
|
array |
toKeyValue(string $keyColumn = 'PrimaryKey', string $valueColumn = null)
Get an associative array representation of the collection The first parameter specifies the column to be used for the key, And the second for the value. |
|
array |
toKeyIndex(string $keyColumn = 'PrimaryKey')
Get an associative array representation of the collection. |
|
ObjectCollection |
populateRelation(string $relation, Criteria $criteria = null, ConnectionInterface $con = null)
Makes an additional query to populate the objects related to the collection objects by a certain relation |
Details
in Collection at line 70
public array
getData()
Get the data in the collection
in Collection at line 80
public
setData(array $data)
Set the data in the collection
in Collection at line 91
public integer
getPosition()
Gets the position of the internal pointer This position can be later used in seek()
in Collection at line 102
public mixed
getFirst()
Move the internal pointer to the beginning of the list And get the first element in the collection
in Collection at line 114
public boolean
isFirst()
Check whether the internal pointer is at the beginning of the list
in Collection at line 125
public mixed
getPrevious()
Move the internal pointer backward And get the previous element in the collection
in Collection at line 141
public mixed
getCurrent()
Get the current element in the collection
in Collection at line 152
public mixed
getNext()
Move the internal pointer forward And get the next element in the collection
in Collection at line 165
public mixed
getLast()
Move the internal pointer to the end of the list And get the last element in the collection
in Collection at line 181
public boolean
isLast()
Check whether the internal pointer is at the end of the list
in Collection at line 198
public boolean
isEmpty()
Check if the collection is empty
in Collection at line 208
public boolean
isOdd()
Check if the current index is an odd integer
in Collection at line 218
public boolean
isEven()
Check if the current index is an even integer
in Collection at line 230
public mixed
get(mixed $key)
Get an element from its key Alias for ArrayObject::offsetGet()
in Collection at line 244
public mixed
pop()
Pops an element off the end of the collection
in Collection at line 262
public mixed
shift()
Pops an element off the beginning of the collection
in Collection at line 279
public integer
prepend(mixed $value)
Prepend one or more elements to the beginning of the collection
in Collection at line 297
public
set(mixed $key, mixed $value)
Add an element to the collection with the given key Alias for ArrayObject::offsetSet()
in Collection at line 309
public mixed
remove(mixed $key)
Removes a specified collection element Alias for ArrayObject::offsetUnset()
in Collection at line 323
public array
clear()
Clears the collection
at line 344
public boolean
contains(mixed $element)
Whether or not this collection contains a specified element
at line 330
public mixed
search(mixed $element)
Search an element in the collection
in Collection at line 357
public Collection
diff(Collection $collection)
Returns an array of objects present in the collection that are not presents in the given collection.
in Collection at line 376
public string
serialize()
in Collection at line 389
public
unserialize(string $data)
in Collection at line 404
public ArrayIterator
getIterator()
Overrides ArrayObject::getIterator() to save the iterator object for internal use e.g.
getNext(), isOdd(), etc.
in Collection at line 414
public ArrayIterator
getInternalIterator()
in Collection at line 429
public
clearIterator()
Clear the internal Iterator.
PHP 5.3 doesn't know how to free a Collection object if it has an attached
Iterator, so this must be done manually to avoid memory leaks.
in Collection at line 441
public
setModel(string $model)
Set the model of the elements in the collection
in Collection at line 456
public string
getModel()
Get the model of the elements in the collection
in Collection at line 466
public string
getFullyQualifiedModel()
Get the model of the elements in the collection
in Collection at line 471
public
getTableMapClass()
in Collection at line 485
public
setFormatter(AbstractFormatter $formatter)
in Collection at line 493
public AbstractFormatter
getFormatter()
in Collection at line 503
public ConnectionInterface
getWriteConnection()
Get a write connection object for the database containing the elements of the collection
in Collection at line 523
public BaseObject
importFrom(mixed $parser, string $data)
Populate the current collection from a string, using a given parser format <code> $coll = new ObjectCollection(); $coll->setModel('Book'); $coll->importFrom('JSON', '{{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}'); </code>
in Collection at line 552
public string
exportTo(mixed $parser, boolean $usePrefix = true, boolean $includeLazyLoadColumns = true)
Export the current collection to a string, using a given parser format <code> $books = BookQuery::create()->find(); echo $book->exportTo('JSON'); => {{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}'); </code>
A OnDemandCollection cannot be exported. Any attempt will result in a PropelException being thrown.
in Collection at line 572
public array|string
__call(string $name, mixed $params)
Catches calls to undefined methods.
Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
Allows to define default __call() behavior if you use a custom BaseObject
in Collection at line 596
public string
__toString()
Returns a string representation of the current collection.
Based on the string representation of the underlying objects, defined in
the TableMap::DEFAULT_STRING_FORMAT constant
in Collection at line 604
public
__clone()
Creates clones of the containing data.
in Collection at line 39
Collection
fromXML(string $data)
Populate the collection from an XML string
in Collection at line 39
Collection
fromYAML(string $data)
Populate the collection from a YAML string
in Collection at line 39
Collection
fromJSON(string $data)
Populate the collection from a JSON string
in Collection at line 39
Collection
fromCSV(string $data)
Populate the collection from a CSV string
in Collection at line 39
string
toXML(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to an XML string
in Collection at line 39
string
toYAML(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to a YAML string
in Collection at line 39
string
toJSON(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to a JSON string
in Collection at line 39
string
toCSV(boolean $usePrefix, boolean $includeLazyLoadColumns)
Export the collection to a CSV string
at line 36
public
save(ConnectionInterface $con = null)
Save all the elements in the collection
at line 62
public
delete(ConnectionInterface $con = null)
Delete all the elements in the collection
at line 89
public array
getPrimaryKeys(boolean $usePrefix = true)
Get an array of the primary keys of all the objects in the collection
at line 109
public
fromArray(array $arr)
Populates the collection from an array Each object is populated from an array and the result is stored Does not empty the collection before adding the data from the array
at line 154
public array
toArray(string $keyColumn = null, boolean $usePrefix = false, string $keyType = TableMap::TYPE_PHPNAME, boolean $includeLazyLoadColumns = true, array $alreadyDumpedObjects = array())
Get an array representation of the collection Each object is turned into an array and the result is returned
at line 197
public array
getArrayCopy(string $keyColumn = null, boolean $usePrefix = false)
Get an array representation of the collection
at line 227
public array
toKeyValue(string $keyColumn = 'PrimaryKey', string $valueColumn = null)
Get an associative array representation of the collection The first parameter specifies the column to be used for the key, And the second for the value.
<code>
$res = $coll->toKeyValue('Id', 'Name');
</code>
at line 257
public array
toKeyIndex(string $keyColumn = 'PrimaryKey')
Get an associative array representation of the collection.
The first parameter specifies the column to be used for the key.
<code>
$res = $userCollection->toKeyIndex('Name');
$res = array(
'peter' => class User #1 {$name => 'peter', ...},
'hans' => class User #2 {$name => 'hans', ...},
...
)
</code>
at line 278
public ObjectCollection
populateRelation(string $relation, Criteria $criteria = null, ConnectionInterface $con = null)
Makes an additional query to populate the objects related to the collection objects by a certain relation