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

0.10 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
compareRecords Compares two records. To be used on _snapshot diffs using array_udiff
boolean contains
integer count
delete single shot delete deletes all records from this collection and uses only one database query to perform this operation
mixed end
exportTo Export a Doctrine_Collection to one of the supported Doctrine_Parser formats
free
fromArray Populate a Doctrine_Collection from an array of data
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
    getDeleteDiff
    mixed getFirst
    getInsertDiff
    object ArrayIterator getIterator
    string getKeyColumn
    array getKeys
    mixed getLast
    Doctrine_Iterator_Normal getNormalIterator
    array getPrimaryKeys
    mixed getReference
    getRelation
    array getSnapshot
    getTable
    importFrom Import data to a Doctrine_Collection from one of the supported Doctrine_Parser formats
    initNullObject
    mixed key
    boolean loadRelated
    merge Merges collection into $this and returns merged collection
    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
    __toString

    Method Details

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

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

      adds a record to collection


    • compareRecords($a, $b)

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


    • $key the key of the element

      (boolean) contains($key)

      contains whether or not this collection contains a specified element


    • (integer) count()

      count this class implements interface countable returns the number of records in this collection


    • delete(( ) $conn = null)

      single shot delete deletes all records from this collection and uses only one database query to perform this operation


    • (mixed) end()

      returns 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)


    • fromArray($array, $deep = true)

      Populate a Doctrine_Collection from an array of data


    • $key the key of the element

      get($key)

      get returns 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()

    getData returns all the records as an array


  • getDeleteDiff()


  • (mixed) getFirst()

    getFirst returns the first record in the collection


  • getInsertDiff()


  • (object ArrayIterator) getIterator()


  • (string) getKeyColumn()

    getKeyColumn returns the name of the key column


  • (array) getKeys()

    returns all keys


  • (mixed) getLast()

    getLast returns the last record in the collection


  • (Doctrine_Iterator_Normal) getNormalIterator()

    getNormalIterator returns normal iterator - an iterator that will not expand this collection


  • (array) getPrimaryKeys()

    Doctrine_Collection


  • (mixed) getReference()


  • getRelation()

    returns the relation object


  • (array) getSnapshot()

    getSnapshot returns the data of the last snapshot

    Doctrine_Collection


  • getTable()

    getTable returns 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)

    initNullObject initializes the null object for this collection


  • (mixed) key()

    returns the current key


  • (boolean) loadRelated($name = null)


  • merge(( ) $coll)

    Merges collection into $this and returns merged collection


  • populateRelated($name, ( ) $coll)


  • processDiff()

    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)

    remove removes a specified collection element


  • $conn optional connection parameter

    save(( ) $conn = null)

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


  • search(( ) $record, $Doctrine_Record)


  • (array) serialize()

    this method is automatically called when this Doctrine_Collection is serialized


  • set($key, ( ) $record)


  • setData($data)


  • setKeyColumn($column)

    setKeyColumn sets the key column for this collection


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

    setReference sets a reference pointer


  • synchronizeFromArray($array)


  • $array representation of a Doctrine_Collection

    synchronizeWithArray($array)

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

    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)

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


  • unserialize($serialized)

    unseralize this method is automatically called everytime a Doctrine_Collection object is unserialized


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

    constructor


  • __toString()

    returns a string representation of this object