Class ActiveRecord_Association_HasMany

Description

Implements the has_many association

Located in /activerecord/lib/ActiveRecord/Association/HasMany.php (line 9)

ActiveRecord_Association
   |
   --ActiveRecord_Association_HasMany
Variable Summary
 static mixed $creation_options
 mixed $order
 mixed $primary_key
Method Summary
 ActiveRecord_Association_HasMany __construct (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, string $name, array $options)
 void add_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, object $value)
 void after_create ( $record)
 void after_save ( $record)
 ActiveRecord_Base build_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $attributes)
 void do_include ( &$results, array $results)
 array find_all (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $options)
 ActiveRecord_Association_Collection get_associates (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, [boolean $force_reload = false])
 string primary_key ()
 void remove_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, object $value)
 void set_associates (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $values, [boolean $skipKeyUpdates = false])
 void set_associate_ids (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $values)
Variables
static mixed $creation_options = array('class_name'=>1, 'foreign_key'=>1, 'primary_key'=>1, 'order'=>1) (line 14)

List of valid options for creation

  • access: public
mixed $order (line 17)
  • access: protected
mixed $primary_key (line 16)
  • access: protected

Inherited Variables

Inherited from ActiveRecord_Association

ActiveRecord_Association::$class_name
ActiveRecord_Association::$foreign_key
ActiveRecord_Association::$name
Methods
Constructor __construct (line 27)

Constructor

  • access: public
ActiveRecord_Association_HasMany __construct (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, string $name, array $options)
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • string $name: The association name
  • array $options: Options for the association
add_associate (line 177)

Add an associated object to this object's collection. This method handles database updates and foreign keys. It does not directly affect the contents of an association collection object.

  • access: public
void add_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, object $value)
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • object $value: The new object to associate with our record
after_create (line 285)

Check the associates to make sure they have been saved

  • access: public
void after_create ( $record)
  • $record
after_save (line 299)

Check the associates to make sure they have been saved

  • access: public
void after_save ( $record)
  • $record
build_associate (line 318)

Build a new associated object from an associative array of attributes and assign it to the object. This method handles database updates and foreign keys. It does not directly affect the contents of an association collection object.

  • access: public
ActiveRecord_Base build_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $attributes)
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • array $attributes: The attributes for the new object to associate with our record
count_associates (line 99)

Called by the collection object to count the associated objects without loading them.

  • return: The associated objects
  • access: public
array count_associates (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy)
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
create_associate (line 341)

Create and save a new associated object from an associative array of attributes and assign it to the object. This method handles database updates and foreign keys. It does not directly affect the contents of an association collection object.

  • access: public
ActiveRecord_Base create_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $attributes)
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • array $attributes: The attributes for the new object to associate with our record
do_include (line 359)

Implements the 'include' behavior for a find operation

  • access: public
void do_include ( &$results, array $results)
  • array $results: The result set to process
  • &$results

Redefinition of:
ActiveRecord_Association::do_include()
Implements the 'include' behavior for a find operation
find_all (line 224)

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

  • return: The list of objects found
  • access: public
array find_all (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $options)
  • ActiveRecord_Base $record: The record object this operation is being performed on
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • array $options: The options for the find operation
get_associates (line 66)

Accessor method for the associated objects

  • return: The collection of associates
  • access: public
ActiveRecord_Association_Collection get_associates (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, [boolean $force_reload = false])
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • boolean $force_reload: If true, forces reloading of the object even if it's cached
get_associate_ids (line 254)

Accessor method for the associated object ids

  • return: The list of associated ids
  • access: public
array get_associate_ids (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy)
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
load_associates (line 81)

Called by the collection object to load the actual associated objects.

  • return: The associated objects
  • access: public
array &load_associates (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy)
  • ActiveRecord_Base $record: An instance of the class the association is being added to
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
primary_key (line 56)

Return the primary key name for this association

  • access: public
string primary_key ()
remove_associate (line 200)

Remove an associated object from this object's collection. This method handles database updates and foreign keys. It does not directly affect the contents of an association collection object.

  • access: public
void remove_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, object $value)
  • ActiveRecord_Base $record: An instance of the class the association is being removed from
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • object $value: The object to remove from our collection
set_associates (line 117)

Mutator method for the entire collection of associated objects

  • access: public
void set_associates (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $values, [boolean $skipKeyUpdates = false])
  • ActiveRecord_Base $record: The instance of the class the association is being set on
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • array $values: The new objects to associate with our record
  • boolean $skipKeyUpdates: This flag exists for include operations assigning associated objects for caching. When this flag is true, the normal foreign key assignment and update steps are skipped and the object is merely placed in the cache.
set_associate_ids (line 269)

Mutator method for the entire collection of associated objects by ids

  • access: public
void set_associate_ids (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $values)
  • ActiveRecord_Base $record: The instance of the class the association is being set on
  • ActiveRecord_Proxy $proxy: A proxy for the class to allow limited access to protected methods
  • array $values: The new object ids to associate with our record

Inherited Methods

Inherited From ActiveRecord_Association

 ActiveRecord_Association::class_name()
 ActiveRecord_Association::do_include()
 ActiveRecord_Association::foreign_key()
 ActiveRecord_Association::name()

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