PHP Class ActiveRecord\AbstractRelationship

See also: http://www.phpactiverecord.org/guides/associations
Inheritance: implements activerecord\InterfaceRelationship
Show file Open project: jpfuentes2/php-activerecord

Public Properties

Property Type Description
$attribute_name string Name to be used that will trigger call to the relationship.
$class_name string Class name of the associated model.
$foreign_key string Name of the foreign key.

Protected Properties

Property Type Description
$options array Options of the relationship.
$poly_relationship boolean Is the relationship single or multi.
$valid_association_options array List of valid options for relationships.

Public Methods

Method Description
__construct ( array $options = [] ) : mixed Constructs a relationship.
build_association ( activerecord\Model $model, array $attributes = [], $guard_attributes = true ) : activerecord\Model Creates a new instance of specified {@link Model} with the attributes pre-loaded.
construct_inner_join_sql ( Table $from_table, boolean $using_through = false, string $alias = null ) : string Creates INNER JOIN SQL for associations.
create_association ( activerecord\Model $model, array $attributes = [], $guard_attributes = true ) : activerecord\Model Creates a new instance of {@link Model} and invokes save.
is_poly ( ) : boolean What is this relationship's cardinality?
load ( activerecord\Model $model ) This will load the related model data.

Protected Methods

Method Description
append_record_to_associate ( activerecord\Model $associate, activerecord\Model $record )
create_conditions_from_keys ( activerecord\Model $model, $condition_keys = [], $value_keys = [] )
get_table ( )
merge_association_options ( $options )
query_and_attach_related_models_eagerly ( Table $table, $models, $attributes, $includes = [], $query_keys = [], $model_values_keys = [] ) : void Eagerly loads relationships for $models.
set_class_name ( $class_name )
set_inferred_class_name ( ) : void Infers the $this->class_name based on $this->attribute_name.
unset_non_finder_options ( $options )

Method Details

__construct() public method

Constructs a relationship.
public __construct ( array $options = [] ) : mixed
$options array Options for the relationship (see {@link valid_association_options})
return mixed

append_record_to_associate() protected method

protected append_record_to_associate ( activerecord\Model $associate, activerecord\Model $record )
$associate activerecord\Model
$record activerecord\Model

build_association() public method

Creates a new instance of specified {@link Model} with the attributes pre-loaded.
public build_association ( activerecord\Model $model, array $attributes = [], $guard_attributes = true ) : activerecord\Model
$model activerecord\Model The model which holds this association
$attributes array Hash containing attributes to initialize the model with
return activerecord\Model

construct_inner_join_sql() public method

Creates INNER JOIN SQL for associations.
public construct_inner_join_sql ( Table $from_table, boolean $using_through = false, string $alias = null ) : string
$from_table Table the table used for the FROM SQL statement
$using_through boolean is this a THROUGH relationship?
$alias string a table alias for when a table is being joined twice
return string SQL INNER JOIN fragment

create_association() public method

Creates a new instance of {@link Model} and invokes save.
public create_association ( activerecord\Model $model, array $attributes = [], $guard_attributes = true ) : activerecord\Model
$model activerecord\Model The model which holds this association
$attributes array Hash containing attributes to initialize the model with
return activerecord\Model

create_conditions_from_keys() protected method

protected create_conditions_from_keys ( activerecord\Model $model, $condition_keys = [], $value_keys = [] )
$model activerecord\Model

get_table() protected method

protected get_table ( )

is_poly() public method

What is this relationship's cardinality?
public is_poly ( ) : boolean
return boolean

load() abstract public method

This will load the related model data.
abstract public load ( activerecord\Model $model )
$model activerecord\Model The model this relationship belongs to

merge_association_options() protected method

protected merge_association_options ( $options )

set_class_name() protected method

protected set_class_name ( $class_name )

set_inferred_class_name() protected method

Will try to guess the appropriate class by singularizing and uppercasing $this->attribute_name.
See also: attribute_name
protected set_inferred_class_name ( ) : void
return void

unset_non_finder_options() protected method

protected unset_non_finder_options ( $options )

Property Details

$attribute_name public property

Name to be used that will trigger call to the relationship.
public string $attribute_name
return string

$class_name public property

Class name of the associated model.
public string $class_name
return string

$foreign_key public property

Name of the foreign key.
public string $foreign_key
return string

$options protected property

Options of the relationship.
protected array $options
return array

$poly_relationship protected property

Is the relationship single or multi.
protected bool $poly_relationship
return boolean

$valid_association_options protected static property

List of valid options for relationships.
protected static array $valid_association_options
return array