Class:Doctrine_Collection - Superclass: Doctrine_Access Class:Doctrine_Access - Superclass: Doctrine_Locator_Injectable Doctrine_Locator_Injectable
⌊ Doctrine_Access
⌊ Doctrine_Collection
public class Doctrine_Collection
extends Doctrine_Access
www.doctrine-project.org
Field Summary | |
---|---|
protected array $_snapshot a snapshot of the fetched data | . |
protected Doctrine_Table $table each collection has only records of specified table | . |
protected array $data an array containing the records of this collection | . |
protected string $keyColumn the name of the column that is used for collection key mapping | . |
protected static Doctrine_Null $null used for extremely fast null value testing | . |
protected Doctrine_Record $reference collection can belong to a record | . |
protected string $referenceField the reference field of the collection | . |
protected Doctrine_Relation the record this collection is related to, if any | . |
Constructor Summary | |
---|---|
Doctrine_Collection(Doctrine_Table|string table, mixed keyColumn) constructor. |
Method Summary | |
---|---|
boolean | add(Doctrine_Record record, string key, mixed value) Adds a record to collection. |
void | clear() Clears the collection.. |
protected integer | compareRecords(Doctrine_Record a, Doctrine_Record b) Compares two records. |
boolean | contains(mixed key, mixed offset) Whether or not this collection contains a specified element. |
integer | count() Gets the number of records in this collection This class implements interface countable. |
static void | create(mixed table, mixed keyColumn, mixed class) |
Doctrine_Collection | delete(mixed conn, mixed clearColl) Deletes all records from this collection. |
Doctrine_Record | end() Get the last record in the collection. |
void | exportTo(string type, string deep) Export a Doctrine_Collection to one of the supported Doctrine_Parser formats. |
void | free(mixed deep) Frees the resources used by the collection. |
void | fromArray(string array, mixed deep) Populate a Doctrine_Collection from an array of data. |
Doctrine_Record | get(mixed key, mixed offset) Gets a record for given key. |
array | getData() Get all the records as an array. |
array | Perform a delete diff between the last snapshot and the current data. |
Doctrine_Record | getFirst() Get the first record in the collection. |
array | Perform a insert diff between the last snapshot and the current data. |
Iterator | Get collection data iterator. |
string | Get the name of the key column. |
array | getKeys() Get all keys of the data in the collection. |
Doctrine_Record | getLast() Get the last record in the collection. |
Doctrine_Iterator_Normal | Get normal iterator - an iterator that will not expand this collection. |
array | Get array of primary keys for all the records in the collection. |
Doctrine_Record | Get reference to Doctrine_Record instance. |
Doctrine_Relation | Returns the relation object. |
array | Gets the data of the last snapshot. |
Doctrine_Table | getTable() Get the table this collection belongs to. |
void | importFrom(string type, string data) Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats. |
static void | initNullObject(Doctrine_Null null) Initializes the null object for this collection. |
final boolean | checks if one of the containing records is modified returns true if modified, false otherwise. |
Doctrine_Record | key() Get the current key. |
boolean | loadRelated(mixed name) Load all relationships or the named relationship passed. |
Doctrine_Collection | merge(Doctrine_Collection coll) Merges collection into $this and returns merged collection. |
void | populateRelated(string name, Doctrine_Collection coll) Populate the relationship $name for all records in the passed collection. |
Doctrine_Collection | Processes the difference of the last snapshot and the current data. |
boolean | remove(mixed key, mixed offset) Removes a specified collection element. |
Doctrine_Collection | save(Doctrine_Connection conn, mixed processDiff) Saves all records of this collection and processes the difference of the last snapshot and the current data. |
void | search(mixed record, string Doctrine_Record) Search a Doctrine_Record instance. |
array | This method is automatically called when this Doctrine_Collection is serialized. |
void | set(integer key, Doctrine_Record record, mixed offset, mixed value) Set a Doctrine_Record instance to the collection. |
Doctrine_Collection | setData(array data) Set the data for the Doctrin_Collection instance. |
Doctrine_Collection | setKeyColumn(string column) Sets the key column for this collection. |
void | setReference(mixed record, mixed relation) Sets a reference pointer. |
void | synchronizeFromArray(mixed array) |
void | synchronizeWithArray(array array) synchronizes a Doctrine_Collection with data from an array. |
Doctrine_Collection | Takes a snapshot from this collection. |
void | toArray(boolean deep, mixed prefixKey) Mimics the result of a $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);. |
void | |
array | toKeyValueArray(string key, string value) Build an array made up of the values from the 2 specified columns. |
void | unserialize(mixed serialized) This method is automatically called everytime a Doctrine_Collection object is unserialized. |
Methods inherited from Doctrine\Doctrine_Access | |
---|---|
add, contains, get, offsetExists, offsetGet, offsetSet, offsetUnset, remove, set, setArray |
Methods inherited from Doctrine\Doctrine_Locator_Injectable | |
---|---|
bind, getLocator, getNullObject, initNullObject, locate, setLocator |
protected array $_snapshot a snapshot of the fetched data $_snapshot = array()
protected Doctrine_Table $table each collection has only records of specified table $_table
protected array $data an array containing the records of this collection $data = array()
protected string $keyColumn the name of the column that is used for collection key mapping $keyColumn
protected static Doctrine_Null $null used for extremely fast null value testing $null
protected Doctrine_Record $reference collection can belong to a record $reference
protected string $referenceField the reference field of the collection $referenceField
protected Doctrine_Relation the record this collection is related to, if any $relation
public Doctrine_Collection(Doctrine_Table|string table, mixed keyColumn)
constructor
public boolean add(Doctrine_Record record, string key, mixed value)
Adds a record to collection
public void clear()
Clears the collection.
protected integer compareRecords(Doctrine_Record a, Doctrine_Record b)
Compares two records. To be used on _snapshot diffs using array_udiff
public boolean contains(mixed key, mixed offset)
Whether or not this collection contains a specified element
public integer count()
Gets the number of records in this collection This class implements interface countable
public static void create(mixed table, mixed keyColumn, mixed class)
public Doctrine_Collection delete(mixed conn, mixed clearColl)
Deletes all records from this collection
public Doctrine_Record end()
Get the last record in the collection
public void exportTo(string type, string deep)
Export a Doctrine_Collection to one of the supported Doctrine_Parser formats
public void free(mixed deep)
Frees the resources used by the collection. WARNING: After invoking free() the collection is no longer considered to be in a useable state. Subsequent usage may result in unexpected behavior.
public void fromArray(string array, mixed deep)
Populate a Doctrine_Collection from an array of data
public Doctrine_Record get(mixed key, mixed offset)
Gets a record for given key
There are two special cases:
1. if null is given as a key a new record is created and attached at the end of the collection
2. if given key does not exist, then a new record is create and attached to the given key
Collection also maps referential information to newly created records
public array getData()
Get all the records as an array
public array getDeleteDiff()
Perform a delete diff between the last snapshot and the current data
public Doctrine_Record getFirst()
Get the first record in the collection
public array getInsertDiff()
Perform a insert diff between the last snapshot and the current data
public Iterator getIterator()
Get collection data iterator
public string getKeyColumn()
Get the name of the key column
public array getKeys()
Get all keys of the data in the collection
public Doctrine_Record getLast()
Get the last record in the collection
public Doctrine_Iterator_Normal getNormalIterator()
Get normal iterator - an iterator that will not expand this collection
public array getPrimaryKeys()
Get array of primary keys for all the records in the collection
public Doctrine_Record getReference()
Get reference to Doctrine_Record instance
public Doctrine_Relation getRelation()
Returns the relation object
public array getSnapshot()
Gets the data of the last snapshot
public Doctrine_Table getTable()
Get the table this collection belongs to
public void importFrom(string type, string data)
Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats
public static void initNullObject(Doctrine_Null null)
Initializes the null object for this collection
public final boolean isModified()
checks if one of the containing records is modified returns true if modified, false otherwise
public Doctrine_Record key()
Get the current key
public boolean loadRelated(mixed name)
Load all relationships or the named relationship passed
public Doctrine_Collection merge(Doctrine_Collection coll)
Merges collection into $this and returns merged collection
public void populateRelated(string name, Doctrine_Collection coll)
Populate the relationship $name for all records in the passed collection
public Doctrine_Collection processDiff()
Processes the difference of the last snapshot and the current data
an example: Snapshot with the objects 1, 2 and 4 Current data with objects 2, 3 and 5
The process would remove object 4
public boolean remove(mixed key, mixed offset)
Removes a specified collection element
public Doctrine_Collection save(Doctrine_Connection conn, mixed processDiff)
Saves all records of this collection and processes the difference of the last snapshot and the current data
public void search(mixed record, string Doctrine_Record)
Search a Doctrine_Record instance
public array serialize()
This method is automatically called when this Doctrine_Collection is serialized
public void set(integer key, Doctrine_Record record, mixed offset, mixed value)
Set a Doctrine_Record instance to the collection
public Doctrine_Collection setData(array data)
Set the data for the Doctrin_Collection instance
public Doctrine_Collection setKeyColumn(string column)
Sets the key column for this collection
public void setReference(mixed record, mixed relation)
Sets a reference pointer
public void synchronizeFromArray(mixed array)
public void synchronizeWithArray(array array)
synchronizes a Doctrine_Collection with data from an array
it expects an array representation of a Doctrine_Collection similar to the return value of the toArray() method. It will create Dectrine_Records that don't exist on the collection, update the ones that do and remove the ones missing in the $array
public Doctrine_Collection takeSnapshot()
Takes a snapshot from this collection
snapshots are used for diff processing, for example when a fetched collection has three elements, then two of those are being removed the diff would contain one element
Doctrine_Collection::save() attaches the diff with the help of last snapshot.
public void toArray(boolean deep, mixed prefixKey)
Mimics the result of a $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
public void toHierarchy()
public array toKeyValueArray(string key, string value)
Build an array made up of the values from the 2 specified columns
public void unserialize(mixed serialized)
This method is automatically called everytime a Doctrine_Collection object is unserialized
Doctrine_Collection Collection of Doctrine_Record objects.