You are currently viewing the 1.0 branch api documentation. Switch to 1.1

1.0 Doctrine_Collection

Doctrine Collection

Doctrine_Collection Collection of Doctrine_Record objects.

Inheritence

Doctrine_Collection  < Doctrine_Access

Direct Sub-Classes

Method Summary

Returns Name Description
boolean add
clear
integer compareRecords
boolean contains
integer count
delete
mixed end
exportTo
free WARNING: After invoking free() the collection is no longer considered to be in a useable state. Subsequent usage may result in unexpected behavior.
fromArray
get There are two special cases:
  • 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 atta
    array getData
    array getDeleteDiff
    mixed getFirst
    array getInsertDiff
    object ArrayIterator getIterator
    string getKeyColumn
    array getKeys
    mixed getLast
    Doctrine_Iterator_Normal getNormalIterator
    array getPrimaryKeys
    getReference
    getRelation
    array getSnapshot
    getTable
    importFrom
    initNullObject
    mixed key
    boolean loadRelated
    merge
    populateRelated
    processDiff an example: Snapshot with the objects 1, 2 and 4 Current data with objects 2, 3 and 5 The process would remove object 4
    boolean remove
    save
    search
    array serialize
    set
    setData
    setKeyColumn
    setReference
    synchronizeFromArray
    synchronizeWithArray 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
    takeSnapshot 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.
    toArray
    unserialize
    __construct
    string __toString

    Method Details

    • $record record to be added
      $key optional key for the record

      (boolean) add((Doctrine_Record) $record, $key = null)

      Adds a record to collection


    • clear()

      Clears the collection.


    • (integer) compareRecords((Doctrine_Record) $a, (Doctrine_Record) $b)

      Compares two records. To be used on _snapshot diffs using array_udiff


    • $key the key of the element

      (boolean) contains($key)

      Whether or not this collection contains a specified element


    • (integer) count()

      Gets the number of records in this collection This class implements interface countable


    • delete(( ) $conn = null, $clearColl = true)

      Deletes all records from this collection


    • (mixed) end()

      Get the last record in the collection


    • exportTo($type, $deep = false)

      Export a Doctrine_Collection to one of the supported Doctrine_Parser formats


    • free($deep = false)

      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.


    • fromArray($array, $deep = true)

      Populate a Doctrine_Collection from an array of data


    • $key the key of the element

      get($key)

      Gets a record for given key

      There are two special cases:


    • 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 atta

      Doctrine_Collection


  • (array) getData()

    Get all the records as an array


  • (array) getDeleteDiff()

    Perform a delete diff between the last snapshot and the current data


  • (mixed) getFirst()

    Get the first record in the collection


  • (array) getInsertDiff()

    Perform a insert diff between the last snapshot and the current data


  • (object ArrayIterator) getIterator()

    Get collection data iterator


  • (string) getKeyColumn()

    Get the name of the key column


  • (array) getKeys()

    Get all keys of the data in the collection


  • (mixed) getLast()

    Get the last record in the collection


  • (Doctrine_Iterator_Normal) getNormalIterator()

    Get normal iterator - an iterator that will not expand this collection


  • (array) getPrimaryKeys()

    Get array of primary keys for all the records in the collection

    Doctrine_Collection


  • getReference()

    Get reference to Doctrine_Record instance


  • getRelation()

    Returns the relation object


  • (array) getSnapshot()

    Gets the data of the last snapshot

    Doctrine_Collection


  • getTable()

    Get the table this collection belongs to


  • importFrom($type, $data)

    Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats


  • initNullObject(( ) $null)

    Initializes the null object for this collection


  • (mixed) key()

    Get the current key


  • (boolean) loadRelated($name = null)

    Load all relationships or the named relationship passed


  • merge(( ) $coll)

    Merges collection into $this and returns merged collection


  • populateRelated($name, ( ) $coll)

    Populate the relationship $name for all records in the passed 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


  • (boolean) remove($key)

    Removes a specified collection element


  • $conn optional connection parameter

    save(( ) $conn = null, $processDiff = true)

    Saves all records of this collection and processes the difference of the last snapshot and the current data


  • search(( ) $record, $Doctrine_Record)

    Search a Doctrine_Record instance


  • (array) serialize()

    This method is automatically called when this Doctrine_Collection is serialized


  • set($key, (Doctrine_Record) $record)

    Set a Doctrine_Record instance to the collection


  • setData($data)

    Set the data for the Doctrin_Collection instance


  • setKeyColumn($column)

    Sets the key column for this collection


  • setReference(( ) $record, ( ) $relation)

    Sets a reference pointer


  • synchronizeFromArray($array)


  • $array representation of a Doctrine_Collection

    synchronizeWithArray($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


  • 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.


  • toArray($deep = false, $prefixKey = false)

    Mimics the result of a $query->execute(array(), Doctrine::HYDRATE_ARRAY);


  • unserialize($serialized)

    This method is automatically called everytime a Doctrine_Collection object is unserialized


  • __construct((Doctrine_Table|string) $table, $keyColumn = null)

    constructor


  • (string) __toString()

    Returns a string representation of this object