Class ActiveRecord_Association_BelongsTo

Description

Implements the belongs_to association

Located in /activerecord/lib/ActiveRecord/Association/BelongsTo.php (line 54)

ActiveRecord_Association
   |
   --ActiveRecord_Association_BelongsTo
Variable Summary
 static mixed $creation_options
Method Summary
 ActiveRecord_Association_BelongsTo __construct (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, string $name, array $options)
 void before_save ( $record)
 ActiveRecord_Base build_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, array $attributes)
 void do_include ( &$results, array $results)
 ActiveRecord_Base get_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, [boolean $force_reload = false])
 void set_associate (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, object $value)
 void set_foreign_key (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, mixed $value)
Variables
static mixed $creation_options = array('class_name'=>1, 'foreign_key'=>1, 'validate_key'=>1) (line 59)

List of valid options for creation

  • access: public

Inherited Variables

Inherited from ActiveRecord_Association

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

Constructor

  • access: public
ActiveRecord_Association_BelongsTo __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
before_save (line 149)

Check the associate to make sure it has been saved

  • access: public
void before_save ( $record)
  • $record
build_associate (line 168)

Build a new associated object from an associative array of attributes and assign it to the 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
create_associate (line 189)

Create and save a new associated object from an associative array of attributes and assign it to the 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 207)

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
get_associate (line 118)

Accessor method for the associated object

  • return: The associated object or null
  • access: public
ActiveRecord_Base get_associate (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
set_associate (line 136)

Mutator method for the associated object

  • access: public
void set_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
set_foreign_key (line 102)

Mutator method for the foreign key. This is redefined to invalidate any cached object.

  • access: public
void set_foreign_key (ActiveRecord_Base $record, ActiveRecord_Proxy $proxy, mixed $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
  • mixed $value: The new key value

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:41 -0700 by phpDocumentor 1.4.3