PHP Класс ActiveRecord\HasMany

# Table: people # Primary key: id # Foreign key: school_id class Person extends ActiveRecord\Model } # Table: schools # Primary key: id class School extends ActiveRecord\Model { static $has_many = array( array('people') ); }); Example using options: class Payment extends ActiveRecord\Model { static $belongs_to = array( array('person'), array('order') ); } class Order extends ActiveRecord\Model { static $has_many = array( array('people', 'through' => 'payments', 'select' => 'people.*, payments.amount', 'conditions' => 'payments.amount < 200') ); }
См. также: http://www.phpactiverecord.org/guides/associations
См. также: valid_association_options
Наследование: extends AbstractRelationship
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$primary_key
$valid_association_options array
  • limit/offset: limit the number of records
  • primary_key: name of the primary_key of the association (defaults to "id")
  • group: GROUP BY clause
  • order: ORDER BY clause
  • through: name of a model

Открытые методы

Метод Описание
__construct ( array $options = [] ) : HasMany Constructs a {@link HasMany} relationship.
build_association ( activerecord\Model $model, $attributes = [], $guard_attributes = true )
create_association ( activerecord\Model $model, $attributes = [], $guard_attributes = true )
load ( activerecord\Model $model )
load_eagerly ( $models = [], $attributes = [], $includes, Table $table )

Защищенные методы

Метод Описание
set_keys ( $model_class_name, $override = false )

Приватные методы

Метод Описание
get_foreign_key_for_new_association ( activerecord\Model $model ) : array Get an array containing the key and value of the foreign key for the association
inject_foreign_key_for_new_association ( activerecord\Model $model, &$attributes )

Описание методов

__construct() публичный Метод

Constructs a {@link HasMany} relationship.
public __construct ( array $options = [] ) : HasMany
$options array Options for the association
Результат HasMany

build_association() публичный Метод

public build_association ( activerecord\Model $model, $attributes = [], $guard_attributes = true )
$model activerecord\Model

create_association() публичный Метод

public create_association ( activerecord\Model $model, $attributes = [], $guard_attributes = true )
$model activerecord\Model

load() публичный Метод

public load ( activerecord\Model $model )
$model activerecord\Model

load_eagerly() публичный Метод

public load_eagerly ( $models = [], $attributes = [], $includes, Table $table )
$table Table

set_keys() защищенный Метод

protected set_keys ( $model_class_name, $override = false )

Описание свойств

$primary_key защищенное свойство

protected $primary_key

$valid_association_options защищенное статическое свойство

  • limit/offset: limit the number of records
  • primary_key: name of the primary_key of the association (defaults to "id")
  • group: GROUP BY clause
  • order: ORDER BY clause
  • through: name of a model
protected static array $valid_association_options
Результат array