# 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')
);
}
파일 보기
프로젝트 열기: jpfuentes2/php-activerecord
프로퍼티 | 타입 | 설명 | |
---|---|---|---|
$primary_key | |||
$valid_association_options | array |
|
메소드 | 설명 | |
---|---|---|
__construct ( array $options = [] ) : |
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, |
메소드 | 설명 | |
---|---|---|
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 ) |
public __construct ( array $options = [] ) : |
||
$options | array | Options for the association |
리턴 |
public build_association ( activerecord\Model $model, $attributes = [], $guard_attributes = true ) | ||
$model | activerecord\Model |
public create_association ( activerecord\Model $model, $attributes = [], $guard_attributes = true ) | ||
$model | activerecord\Model |
public load_eagerly ( $models = [], $attributes = [], $includes, |
||
$table |
protected static array $valid_association_options | ||
리턴 | array |