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
파일 보기 프로젝트 열기: jpfuentes2/php-activerecord

보호된 프로퍼티들

프로퍼티 타입 설명
$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