Class

PropelObjectCollection

class PropelObjectCollection extends PropelCollection

Class for iterating over a list of Propel objects

Methods

array getData()

Get the data in the collection

from PropelCollection
setData(array $data)

Set the data in the collection

from PropelCollection
integer getPosition()

Gets the position of the internal pointer This position can be later used in seek()

from PropelCollection
mixed getFirst()

Move the internal pointer to the beginning of the list And get the first element in the collection

from PropelCollection
boolean isFirst()

Check whether the internal pointer is at the beginning of the list

from PropelCollection
mixed getPrevious()

Move the internal pointer backward And get the previous element in the collection

from PropelCollection
mixed getCurrent()

Get the current element in the collection

from PropelCollection
mixed getNext()

Move the internal pointer forward And get the next element in the collection

from PropelCollection
mixed getLast()

Move the internal pointer to the end of the list And get the last element in the collection

from PropelCollection
boolean isLast()

Check whether the internal pointer is at the end of the list

from PropelCollection
boolean isEmpty()

Check if the collection is empty

from PropelCollection
boolean isOdd()

Check if the current index is an odd integer

from PropelCollection
boolean isEven()

Check if the current index is an even integer

from PropelCollection
mixed get(mixed $key)

Get an element from its key Alias for ArrayObject::offsetGet()

from PropelCollection
mixed pop()

Pops an element off the end of the collection

from PropelCollection
mixed shift()

Pops an element off the beginning of the collection

from PropelCollection
integer prepend(mixed $value)

Prepend one or more elements to the beginning of the collection

from PropelCollection
set(mixed $key, mixed $value)

Add an element to the collection with the given key Alias for ArrayObject::offsetSet()

from PropelCollection
mixed remove(mixed $key)

Removes a specified collection element Alias for ArrayObject::offsetUnset()

from PropelCollection
array clear()

Clears the collection

from PropelCollection
boolean contains(mixed $element)

Whether or not this collection contains a specified element

mixed search(mixed $element)

Search an element in the collection

PropelCollection diff(PropelCollection $collection)

Returns an array of objects present in the collection that are not presents in the given collection.

from PropelCollection
string serialize()

from PropelCollection
void unserialize(string $data)

from PropelCollection
ArrayIterator getIterator()

Overrides ArrayObject::getIterator() to save the iterator object for internal use e.g.

from PropelCollection
ArrayIterator getInternalIterator()

from PropelCollection
clearIterator()

Clear the internal Iterator.

from PropelCollection
setModel(string $model)

Set the model of the elements in the collection

from PropelCollection
string getModel()

Get the model of the elements in the collection

from PropelCollection
string getPeerClass()

Get the peer class of the elements in the collection

from PropelCollection
setFormatter(PropelFormatter $formatter)

from PropelCollection
PropelFormatter getFormatter()

from PropelCollection
PropelPDO getConnection(string $type = Propel::CONNECTION_READ)

Get a connection object for the database containing the elements of the collection

from PropelCollection
BaseObject importFrom(mixed $parser, string $data)

Populate the current collection from a string, using a given parser format $coll = new PropelObjectCollection(); $coll->setModel('Book'); $coll->importFrom('JSON', '{{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}');

from PropelCollection
string exportTo(mixed $parser, boolean $usePrefix = true, boolean $includeLazyLoadColumns = true)

Export the current collection to a string, using a given parser format $books = BookQuery::create()->find(); echo $book->exportTo('JSON'); => {{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}');

from PropelCollection
array|string __call(string $name, mixed $params)

Catches calls to undefined methods.

from PropelCollection
string __toString()

Returns a string representation of the current collection.

from PropelCollection
__clone()

Creates clones of the containing data.

from PropelCollection
array toArray(string $keyColumn = null, boolean $usePrefix = false, string $keyType = BasePeer::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

from PropelCollection
PropelCollection fromXML(string $data)

Populate the collection from an XML string

from PropelCollection
PropelCollection fromYAML(string $data)

Populate the collection from a YAML string

from PropelCollection
PropelCollection fromJSON(string $data)

Populate the collection from a JSON string

from PropelCollection
PropelCollection fromCSV(string $data)

Populate the collection from a CSV string

from PropelCollection
string toXML(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to an XML string

from PropelCollection
string toYAML(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to a YAML string

from PropelCollection
string toJSON(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to a JSON string

from PropelCollection
string toCSV(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to a CSV string

from PropelCollection
save(PropelPDO $con = null)

Save all the elements in the collection

delete(PropelPDO $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 getArrayCopy(string $keyColumn = null, boolean $usePrefix = false)

Get an array representation of the collection

array toKeyValue(string|array $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 seconf for the value.

PropelObjectCollection populateRelation(string $relation, Criteria $criteria = null, PropelPDO $con = null)

Makes an additional query to populate the objects related to the collection objects by a certain relation

Details

in PropelCollection at line 52
public array getData()

Get the data in the collection

Return Value

array

in PropelCollection at line 62
public setData(array $data)

Set the data in the collection

Parameters

array $data

in PropelCollection at line 73
public integer getPosition()

Gets the position of the internal pointer This position can be later used in seek()

Return Value

integer

in PropelCollection at line 84
public mixed getFirst()

Move the internal pointer to the beginning of the list And get the first element in the collection

Return Value

mixed

in PropelCollection at line 96
public boolean isFirst()

Check whether the internal pointer is at the beginning of the list

Return Value

boolean

in PropelCollection at line 107
public mixed getPrevious()

Move the internal pointer backward And get the previous element in the collection

Return Value

mixed

in PropelCollection at line 124
public mixed getCurrent()

Get the current element in the collection

Return Value

mixed

in PropelCollection at line 135
public mixed getNext()

Move the internal pointer forward And get the next element in the collection

Return Value

mixed

in PropelCollection at line 148
public mixed getLast()

Move the internal pointer to the end of the list And get the last element in the collection

Return Value

mixed

in PropelCollection at line 165
public boolean isLast()

Check whether the internal pointer is at the end of the list

Return Value

boolean

in PropelCollection at line 181
public boolean isEmpty()

Check if the collection is empty

Return Value

boolean

in PropelCollection at line 191
public boolean isOdd()

Check if the current index is an odd integer

Return Value

boolean

in PropelCollection at line 201
public boolean isEven()

Check if the current index is an even integer

Return Value

boolean

in PropelCollection at line 216
public mixed get(mixed $key)

Get an element from its key Alias for ArrayObject::offsetGet()

Parameters

mixed $key

Return Value

mixed The element

Exceptions

PropelException

in PropelCollection at line 230
public mixed pop()

Pops an element off the end of the collection

Return Value

mixed The popped element

in PropelCollection at line 247
public mixed shift()

Pops an element off the beginning of the collection

Return Value

mixed The popped element

in PropelCollection at line 265
public integer prepend(mixed $value)

Prepend one or more elements to the beginning of the collection

Parameters

mixed $value the element to prepend

Return Value

integer The number of new elements in the array

in PropelCollection at line 283
public set(mixed $key, mixed $value)

Add an element to the collection with the given key Alias for ArrayObject::offsetSet()

Parameters

mixed $key
mixed $value

in PropelCollection at line 298
public mixed remove(mixed $key)

Removes a specified collection element Alias for ArrayObject::offsetUnset()

Parameters

mixed $key

Return Value

mixed The removed element

Exceptions

PropelException

in PropelCollection at line 312
public array clear()

Clears the collection

Return Value

array The previous collection

at line 289
public boolean contains(mixed $element)

Whether or not this collection contains a specified element

Parameters

mixed $element

Return Value

boolean

Search an element in the collection

Parameters

mixed $element

Return Value

mixed Returns the key for the element if it is found in the collection, FALSE otherwise

in PropelCollection at line 349
public PropelCollection diff(PropelCollection $collection)

Returns an array of objects present in the collection that are not presents in the given collection.

Parameters

PropelCollection $collection A Propel collection.

Return Value

PropelCollection An array of Propel objects from the collection that are not presents in the given collection.

in PropelCollection at line 368
public string serialize()

Return Value

string

in PropelCollection at line 383
public void unserialize(string $data)

Parameters

string $data

Return Value

void

in PropelCollection at line 398
public ArrayIterator getIterator()

Overrides ArrayObject::getIterator() to save the iterator object for internal use e.g.

getNext(), isOdd(), etc.

Return Value

ArrayIterator

in PropelCollection at line 408
public ArrayIterator getInternalIterator()

Return Value

ArrayIterator

in PropelCollection at line 424
public clearIterator()

Clear the internal Iterator.

PHP 5.3 doesn't know how to free a PropelCollection object if it has an attached Iterator, so this must be done manually to avoid memory leaks.

See also

http://www.propelorm.org/ticket/1232

in PropelCollection at line 436
public setModel(string $model)

Set the model of the elements in the collection

Parameters

string $model Name of the Propel object classes stored in the collection

in PropelCollection at line 446
public string getModel()

Get the model of the elements in the collection

Return Value

string Name of the Propel object class stored in the collection

in PropelCollection at line 458
public string getPeerClass()

Get the peer class of the elements in the collection

Return Value

string Name of the Propel peer class stored in the collection

Exceptions

PropelException

in PropelCollection at line 470
public setFormatter(PropelFormatter $formatter)

Parameters

PropelFormatter $formatter

in PropelCollection at line 478
public PropelFormatter getFormatter()

Return Value

PropelFormatter

in PropelCollection at line 490
public PropelPDO getConnection(string $type = Propel::CONNECTION_READ)

Get a connection object for the database containing the elements of the collection

Parameters

string $type The connection type (Propel::CONNECTIONREAD by default; can be Propel::connectionWRITE)

Return Value

PropelPDO A PropelPDO connection object

in PropelCollection at line 510
public BaseObject importFrom(mixed $parser, string $data)

Populate the current collection from a string, using a given parser format $coll = new PropelObjectCollection(); $coll->setModel('Book'); $coll->importFrom('JSON', '{{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}');

Parameters

mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
string $data The source data to import from

Return Value

BaseObject The current object, for fluid interface

in PropelCollection at line 540
public string exportTo(mixed $parser, boolean $usePrefix = true, boolean $includeLazyLoadColumns = true)

Export the current collection to a string, using a given parser format $books = BookQuery::create()->find(); echo $book->exportTo('JSON'); => {{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}');

A PropelOnDemandCollection cannot be exported. Any attempt will result in a PropelExecption being thrown.

Parameters

mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
boolean $usePrefix (optional) If true, the returned element keys will be prefixed with the model class name ('Article0', 'Article1', etc). Defaults to TRUE. Not supported by PropelArrayCollection, as PropelArrayFormatter has already created the array used here with integers as keys.
boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. Not supported by PropelArrayCollection, as PropelArrayFormatter has already included lazy-load columns in the array used here.

Return Value

string The exported data

in PropelCollection at line 562
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

Parameters

string $name
mixed $params

Return Value

array|string

Exceptions

PropelException

in PropelCollection at line 583
public string __toString()

Returns a string representation of the current collection.

Based on the string representation of the underlying objects, defined in the Peer::DEFAULTSTRINGFORMAT constant

Return Value

string

in PropelCollection at line 591
public __clone()

Creates clones of the containing data.

in PropelCollection at line 637
public array toArray(string $keyColumn = null, boolean $usePrefix = false, string $keyType = BasePeer::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

Parameters

string $keyColumn If null, the returned array uses an incremental index. Otherwise, the array is indexed using the specified column
boolean $usePrefix If true, the returned array prefixes keys with the model class name ('Article0', 'Article1', etc).
string $keyType (optional) One of the class type constants BasePeer::TYPEPHPNAME, BasePeer::TYPESTUDLYPHPNAME, BasePeer::TYPECOLNAME, BasePeer::TYPEFIELDNAME, BasePeer::TYPENUM. Defaults to BasePeer::TYPEPHPNAME.
boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
array $alreadyDumpedObjects List of objects to skip to avoid recursion $bookCollection->toArray(); array( 0 => array('Id' => 123, 'Title' => 'War And Peace'), 1 => array('Id' => 456, 'Title' => 'Don Juan'), ) $bookCollection->toArray('Id'); array( 123 => array('Id' => 123, 'Title' => 'War And Peace'), 456 => array('Id' => 456, 'Title' => 'Don Juan'), ) $bookCollection->toArray(null, true); array( 'Book0' => array('Id' => 123, 'Title' => 'War And Peace'), 'Book1' => array('Id' => 456, 'Title' => 'Don Juan'), )

Return Value

array

in PropelCollection at line 28
PropelCollection fromXML(string $data)

Populate the collection from an XML string

Parameters

string $data

Return Value

PropelCollection

in PropelCollection at line 28
PropelCollection fromYAML(string $data)

Populate the collection from a YAML string

Parameters

string $data

Return Value

PropelCollection

in PropelCollection at line 28
PropelCollection fromJSON(string $data)

Populate the collection from a JSON string

Parameters

string $data

Return Value

PropelCollection

in PropelCollection at line 28
PropelCollection fromCSV(string $data)

Populate the collection from a CSV string

Parameters

string $data

Return Value

PropelCollection

in PropelCollection at line 28
string toXML(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to an XML string

Parameters

boolean $usePrefix
boolean $includeLazyLoadColumns

Return Value

string

in PropelCollection at line 28
string toYAML(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to a YAML string

Parameters

boolean $usePrefix
boolean $includeLazyLoadColumns

Return Value

string

in PropelCollection at line 28
string toJSON(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to a JSON string

Parameters

boolean $usePrefix
boolean $includeLazyLoadColumns

Return Value

string

in PropelCollection at line 28
string toCSV(boolean $usePrefix, boolean $includeLazyLoadColumns)

Export the collection to a CSV string

Parameters

boolean $usePrefix
boolean $includeLazyLoadColumns

Return Value

string

at line 26
public save(PropelPDO $con = null)

Save all the elements in the collection

Parameters

PropelPDO $con

Exceptions

PropelException

at line 54
public delete(PropelPDO $con = null)

Delete all the elements in the collection

Parameters

PropelPDO $con

Exceptions

PropelException

at line 82
public array getPrimaryKeys(boolean $usePrefix = true)

Get an array of the primary keys of all the objects in the collection

Parameters

boolean $usePrefix

Return Value

array The list of the primary keys of the collection

at line 102
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

Parameters

array $arr

at line 141
public array getArrayCopy(string $keyColumn = null, boolean $usePrefix = false)

Get an array representation of the collection

Parameters

string $keyColumn If null, the returned array uses an incremental index. Otherwise, the array is indexed using the specified column
boolean $usePrefix If true, the returned array prefixes keys with the model class name ('Article0', 'Article1', etc). $bookCollection->getArrayCopy(); array( 0 => $book0, 1 => $book1, ) $bookCollection->getArrayCopy('Id'); array( 123 => $book0, 456 => $book1, ) $bookCollection->getArrayCopy(null, true); array( 'Book0' => $book0, 'Book1' => $book1, )

Return Value

array

at line 174
public array toKeyValue(string|array $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 seconf for the value.

$res = $coll->toKeyValue('Id', 'Name'); $res = $coll->toKeyValue(array('RelatedModel', 'Name'), 'Name');

Parameters

string|array $keyColumn The name of the column, or a list of columns to call.
string $valueColumn

Return Value

array

at line 224
public PropelObjectCollection populateRelation(string $relation, Criteria $criteria = null, PropelPDO $con = null)

Makes an additional query to populate the objects related to the collection objects by a certain relation

Parameters

string $relation Relation name (e.g. 'Book')
Criteria $criteria Optional Criteria object to filter the related object collection
PropelPDO $con Optional connection object

Return Value

PropelObjectCollection The list of related objects

Exceptions

PropelException