class Doctrine_Collection_Offset extends Doctrine_Collection (View source)

Doctrine_Collection_Offset Collection of Doctrine_Record objects.

Properties

protected Doctrine_Locator $_locator from Doctrine_Locator_Injectable
protected array $_resources from Doctrine_Locator_Injectable
static protected Doctrine_Null $_null from Doctrine_Locator_Injectable
protected array $data from Doctrine_Collection
protected Doctrine_Table $_table from Doctrine_Collection
protected array $_snapshot from Doctrine_Collection
protected Doctrine_Record $reference from Doctrine_Collection
protected string $referenceField from Doctrine_Collection
protected Doctrine_Relation $relation from Doctrine_Collection
protected string $keyColumn from Doctrine_Collection
static protected Doctrine_Null $null from Doctrine_Collection

Methods

setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

getLocator()

getLocator returns the locator associated with this object

mixed
locate(string $name)

locate locates a resource by given name and returns it

bind($name, $resource)

bind binds a resource to a name

static void
initNullObject(Doctrine_Null $null)

Initializes the null object for this collection

static Doctrine_Null
getNullObject()

getNullObject returns the null object associated with this object

setArray(array $array)

Set an entire aray to the data

void
__set($name, $value)

Set key and value to data

mixed
__get(mixed $name)

Get key from data

boolean
__isset(string $name)

Check if key exists in data

void
__unset(string $name)

Remove key from data

boolean
offsetExists(mixed $offset)

Check if an offset axists

mixed
offsetGet(mixed $offset)

An alias of get()

void
offsetSet(mixed $offset, mixed $value)

Sets $offset to $value

offsetUnset(mixed $offset)

Unset a given offset

boolean
remove(mixed $key)

Removes a specified collection element

mixed
get(mixed $key)

Gets a record for given key

set(integer $key, Doctrine_Record $record)

Set a Doctrine_Record instance to the collection

boolean
contains(mixed $key)

Whether or not this collection contains a specified element

void
add(Doctrine_Record $record, string $key = null)

Adds a record to collection

__construct($table)

No description

static 
create($table, $keyColumn = null, $class = null)

No description

getTable()

Get the table this collection belongs to

setData(array $data)

Set the data for the Doctrin_Collection instance

array
serialize()

This method is automatically called when this Doctrine_Collection is serialized

void
unserialize($serialized)

This method is automatically called everytime a Doctrine_Collection object is unserialized

setKeyColumn(string $column)

Sets the key column for this collection

string
getKeyColumn()

Get the name of the key column

array
getData()

Get all the records as an array

getFirst()

Get the first record in the collection

getLast()

Get the last record in the collection

end()

Get the last record in the collection

key()

Get the current key

void
setReference(Doctrine_Record $record, Doctrine_Relation $relation)

Sets a reference pointer

getReference()

Get reference to Doctrine_Record instance

void
search(Doctrine_Record $record)

Search a Doctrine_Record instance

array
getPrimaryKeys()

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

array
getKeys()

Get all keys of the data in the collection

integer
count()

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

merge(Doctrine_Collection $coll)

Merges collection into $this and returns merged collection

boolean
loadRelated(mixed $name = null)

Load all relationships or the named relationship passed

void
populateRelated(string $name, Doctrine_Collection $coll)

Populate the relationship $name for all records in the passed collection

Doctrine_Iterator_Normal
getNormalIterator()

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

takeSnapshot()

Takes a snapshot from this collection

array
getSnapshot()

Gets the data of the last snapshot

processDiff()

Processes the difference of the last snapshot and the current data

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

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

array
toKeyValueArray(string $key, string $value)

Build an array made up of the values from the 2 specified columns

toHierarchy()

No description

void
fromArray($array, $deep = true)

Populate a Doctrine_Collection from an array of data

synchronizeWithArray(array $array)

synchronizes a Doctrine_Collection with data from an array

synchronizeFromArray(array $array)

No description

void
exportTo(string $type, string $deep = true)

Export a Doctrine_Collection to one of the supported Doctrine_Parser formats

void
importFrom(string $type, string $data)

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

array
getDeleteDiff()

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

array
getInsertDiff()

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

integer
compareRecords(Doctrine_Record $a, Doctrine_Record $b)

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

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

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

replace(Doctrine_Connection $conn = null, $processDiff = true)

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

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

Deletes all records from this collection

void
clear()

Clears the collection.

void
free($deep = false)

Frees the resources used by the collection.

getIterator()

No description

string
__toString()

Returns a string representation of this object

getRelation()

Returns the relation object

boolean
isModified()

checks if one of the containing records is modified returns true if modified, false otherwise

integer
getLimit()

No description

Details

Doctrine_Locator_Injectable setLocator(Doctrine_Locator $locator)

setLocator this method can be used for setting the locator object locally

Parameters

Doctrine_Locator $locator the locator object

Return Value

Doctrine_Locator_Injectable this instance

Doctrine_Locator getLocator()

getLocator returns the locator associated with this object

if there are no locator locally associated then this method tries to fetch the current global locator

Return Value

Doctrine_Locator

mixed locate(string $name)

locate locates a resource by given name and returns it

if the resource cannot be found locally this method tries to use the global locator for finding the resource

Parameters

string $name the name of the resource

Return Value

mixed the located resource

Exceptions

Doctrine_Locator_Exception if the resource could not be found

See also

Doctrine_Locator::locate

Doctrine_Locator bind($name, $resource)

bind binds a resource to a name

Parameters

$name
$resource

Return Value

Doctrine_Locator this object

static void initNullObject(Doctrine_Null $null)

Initializes the null object for this collection

Parameters

Doctrine_Null $null

Return Value

void

static Doctrine_Null getNullObject()

getNullObject returns the null object associated with this object

Return Value

Doctrine_Null

Doctrine_Access setArray(array $array)

Set an entire aray to the data

Parameters

array $array An array of key => value pairs

Return Value

Doctrine_Access

void __set($name, $value)

Set key and value to data

Parameters

$name
$value

Return Value

void

See also

set, offsetSet

mixed __get(mixed $name)

Get key from data

Parameters

mixed $name

Return Value

mixed

See also

get, offsetGet

boolean __isset(string $name)

Check if key exists in data

Parameters

string $name

Return Value

boolean whether or not this object contains $name

void __unset(string $name)

Remove key from data

Parameters

string $name

Return Value

void

boolean offsetExists(mixed $offset)

Check if an offset axists

Parameters

mixed $offset

Return Value

boolean Whether or not this object contains $offset

mixed offsetGet(mixed $offset)

An alias of get()

Parameters

mixed $offset

Return Value

mixed

See also

get, __get

void offsetSet(mixed $offset, mixed $value)

Sets $offset to $value

Parameters

mixed $offset
mixed $value

Return Value

void

See also

set, __set

offsetUnset(mixed $offset)

Unset a given offset

Parameters

mixed $offset

See also

set, offsetSet, __set

boolean remove(mixed $key)

Removes a specified collection element

Parameters

mixed $key

Return Value

boolean True if removed otherwise false

mixed get(mixed $key)

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

Parameters

mixed $key the key of the element

Return Value

mixed

set(integer $key, Doctrine_Record $record)

Set a Doctrine_Record instance to the collection

Parameters

integer $key
Doctrine_Record $record

boolean contains(mixed $key)

Whether or not this collection contains a specified element

Parameters

mixed $key the key of the element

Return Value

boolean True if exists otherwise false

void add(Doctrine_Record $record, string $key = null)

Adds a record to collection

Parameters

Doctrine_Record $record record to be added
string $key optional key for the record

Return Value

void

__construct($table)

Parameters

$table

static create($table, $keyColumn = null, $class = null)

Parameters

$table
$keyColumn
$class

Doctrine_Table getTable()

Get the table this collection belongs to

Return Value

Doctrine_Table

Doctrine_Collection setData(array $data)

Set the data for the Doctrin_Collection instance

Parameters

array $data

Return Value

Doctrine_Collection

array serialize()

This method is automatically called when this Doctrine_Collection is serialized

Return Value

array

void unserialize($serialized)

This method is automatically called everytime a Doctrine_Collection object is unserialized

Parameters

$serialized

Return Value

void

Doctrine_Collection setKeyColumn(string $column)

Sets the key column for this collection

Parameters

string $column

Return Value

Doctrine_Collection $this

string getKeyColumn()

Get the name of the key column

Return Value

string

array getData()

Get all the records as an array

Return Value

array

Doctrine_Record getFirst()

Get the first record in the collection

Return Value

Doctrine_Record

Doctrine_Record getLast()

Get the last record in the collection

Return Value

Doctrine_Record

Doctrine_Record end()

Get the last record in the collection

Return Value

Doctrine_Record

Doctrine_Record key()

Get the current key

Return Value

Doctrine_Record

void setReference(Doctrine_Record $record, Doctrine_Relation $relation)

Sets a reference pointer

Parameters

Doctrine_Record $record
Doctrine_Relation $relation

Return Value

void

Doctrine_Record getReference()

Get reference to Doctrine_Record instance

Return Value

Doctrine_Record $reference

Search a Doctrine_Record instance

Parameters

Doctrine_Record $record

Return Value

void

array getPrimaryKeys()

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

Return Value

array an array containing all primary keys

array getKeys()

Get all keys of the data in the collection

Return Value

array

integer count()

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

Return Value

integer

Doctrine_Collection merge(Doctrine_Collection $coll)

Merges collection into $this and returns merged collection

Parameters

Doctrine_Collection $coll

Return Value

Doctrine_Collection

boolean loadRelated(mixed $name = null)

Load all relationships or the named relationship passed

Parameters

mixed $name

Return Value

boolean

void populateRelated(string $name, Doctrine_Collection $coll)

Populate the relationship $name for all records in the passed collection

Parameters

string $name
Doctrine_Collection $coll

Return Value

void

Doctrine_Iterator_Normal getNormalIterator()

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

Return Value

Doctrine_Iterator_Normal $iterator

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.

Return Value

Doctrine_Collection

array getSnapshot()

Gets the data of the last snapshot

Return Value

array returns the data in last snapshot

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

Return Value

Doctrine_Collection

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

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

Parameters

$deep
$prefixKey

array toKeyValueArray(string $key, string $value)

Build an array made up of the values from the 2 specified columns

Parameters

string $key
string $value

Return Value

array $result

toHierarchy()

void fromArray($array, $deep = true)

Populate a Doctrine_Collection from an array of data

Parameters

$array
$deep

Return Value

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

Parameters

array $array representation of a Doctrine_Collection

synchronizeFromArray(array $array)

Parameters

array $array

void exportTo(string $type, string $deep = true)

Export a Doctrine_Collection to one of the supported Doctrine_Parser formats

Parameters

string $type
string $deep

Return Value

void

void importFrom(string $type, string $data)

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

Parameters

string $type
string $data

Return Value

void

array getDeleteDiff()

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

Return Value

array $diff

array getInsertDiff()

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

Return Value

array $diff

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

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

Parameters

Doctrine_Record $a
Doctrine_Record $b

Return Value

integer

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

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

Parameters

Doctrine_Connection $conn
$processDiff

Return Value

Doctrine_Collection

Doctrine_Collection replace(Doctrine_Connection $conn = null, $processDiff = true)

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

Parameters

Doctrine_Connection $conn
$processDiff

Return Value

Doctrine_Collection

Doctrine_Collection delete(Doctrine_Connection $conn = null, $clearColl = true)

Deletes all records from this collection

Parameters

Doctrine_Connection $conn
$clearColl

Return Value

Doctrine_Collection

void clear()

Clears the collection.

Return Value

void

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

Parameters

$deep

Return Value

void

Iterator getIterator()

Return Value

Iterator

string __toString()

Returns a string representation of this object

Return Value

string $string

Doctrine_Relation getRelation()

Returns the relation object

Return Value

Doctrine_Relation

final boolean isModified()

checks if one of the containing records is modified returns true if modified, false otherwise

Return Value

boolean

integer getLimit()

Return Value

integer