Class ActiveRecord_Association_Collection

Description

Implements interfaces:

  • IteratorAggregate (internal interface)
  • ArrayAccess (internal interface)
  • Countable (internal interface)

The collection of associates in a has many association. In addition to the documented methods, the collection object may be treated as an array (iterated over, accessed with square brackets, etc.).

Located in /activerecord/lib/ActiveRecord/Association/Collection.php (line 11)


	
			
Variable Summary
 mixed $associates
 mixed $association
 mixed $count
 mixed $proxy
 mixed $record
Method Summary
 ActiveRecord_Association_Collection __construct (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, ActiveRecord_Assocation $association, [array $associates = null])
 array &associates ()
 void build (array $attributes)
 void clear ()
 int count ()
 void create (array $attributes)
 void delete (ActiveRecord_Base $associate)
 bool exists (mixed $test)
 mixed find ()
 array find_all (array $options)
 mixed find_first (array $options)
 ArrayIterator getIterator ()
 boolean is_empty ()
 int length ()
 boolean offsetExists (int $offset)
 boolean offsetGet (int $offset)
 void offsetSet (int $offset, ActiveRecord_Base $value)
 void offsetUnset (int $offset)
 int size ()
Variables
mixed $associates (line 16)
  • access: protected
mixed $association (line 15)
  • access: protected
mixed $count (line 17)
  • access: protected
mixed $proxy (line 14)
  • access: protected
mixed $record (line 13)
  • access: protected
Methods
Constructor __construct (line 27)

Constructor

  • access: public
ActiveRecord_Association_Collection __construct (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, ActiveRecord_Assocation $association, [array $associates = null])
  • ActiveRecord_Base $record: The record we're associated with
  • ActiveRecord_Proxy $proxy: The proxy for the records protected methods
  • ActiveRecord_Assocation $association: The association we represent a collection of
  • array $associates: Optionally allows the initial collection contents to be specified
associates (line 45)

Returns the array of associate objects

  • access: protected
array &associates ()
build (line 270)

Construct a new associate from a set of attributes and add it to the collection.

  • access: public
void build (array $attributes)
  • array $attributes: The attributes for the new associate
clear (line 151)

Clear all associates from the collection

  • access: public
void clear ()
count (line 73)

Returns the number of associated objects in the collection (same as size())

  • access: public
int count ()

Implementation of:
Countable::count
create (line 284)

Construct a new associate and save it (validation permitting) from a set of attributes and add it to the collection.

  • access: public
void create (array $attributes)
  • array $attributes: The attributes for the new associate
delete (line 254)

Remove the associate from the collection

  • access: public
void delete (ActiveRecord_Base $associate)
exists (line 239)

Similar to ActiveRecord_Base::exists(), but limited to items within this collection.

  • access: public
bool exists (mixed $test)
  • mixed $test: The id or conditions to test for
find (line 175)

Similar to ActiveRecord_Base::find(), but limited to items within this collection.

  • return: The object or list of objects.
  • access: public
mixed find ()
find_all (line 227)

Similar to ActiveRecord_Base::find_all(), but limited to items within this collection.

  • return: The list of objects found
  • access: public
array find_all (array $options)
  • array $options: The options for the find operation
find_first (line 210)

Similar to ActiveRecord_Base::find_first(), but limited to items within this collection.

  • return: The first object found or NULL
  • access: public
mixed find_first (array $options)
  • array $options: The options for the find operation
getIterator (line 87)

Returns an iterator for this collections objects

  • access: public
ArrayIterator getIterator ()

Implementation of:
IteratorAggregate::getIterator
is_empty (line 165)

Test the collection to see if it is empty

  • return: True if the collection is empty, false otherwise
  • access: public
boolean is_empty ()
length (line 80)

Returns the number of associated objects in the collection (same as size())

  • access: public
int length ()
offsetExists (line 97)

Test for the existence of a given offset

  • access: public
boolean offsetExists (int $offset)
  • int $offset: The offset to test

Implementation of:
ArrayAccess::offsetExists
offsetGet (line 108)

Get the associate at a given offset

  • access: public
boolean offsetGet (int $offset)
  • int $offset: The offset to get

Implementation of:
ArrayAccess::offsetGet
offsetSet (line 119)

Set the associate at a given offset

  • access: public
void offsetSet (int $offset, ActiveRecord_Base $value)
  • int $offset: The offset to set the associate at
  • ActiveRecord_Base $value: The associate to set

Implementation of:
ArrayAccess::offsetSet
offsetUnset (line 138)

Unset the associate at a given offset

  • access: public
void offsetUnset (int $offset)
  • int $offset: The offset to unset

Implementation of:
ArrayAccess::offsetUnset
size (line 58)

Returns the number of associated objects in the collection

  • access: public
int size ()

Documentation generated on Wed, 25 Apr 2012 09:46:41 -0700 by phpDocumentor 1.4.3