ICanBoogie/ActiveRecord 3.0.x
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • ActiveRecord
      • ActiveRecordCache
      • Driver
      • Property
      • Validate
        • Reader
        • Validator
        • ValidatorProvider

Classes

  • BelongsToRelation
  • Connection
  • ConnectionCollection
  • ConnectionOptions
  • HasManyRelation
  • Helpers
  • Model
  • ModelCollection
  • Query
  • Relation
  • RelationCollection
  • RelationNotDefined
  • Schema
  • SchemaColumn
  • Statement
  • Table

Interfaces

  • ActiveRecordCache
  • Driver
  • Exception

Exceptions

  • ActiveRecordClassNotValid
  • ConnectionAlreadyEstablished
  • ConnectionNotDefined
  • ConnectionNotEstablished
  • DriverNotDefined
  • ModelAlreadyInstantiated
  • ModelNotDefined
  • RecordNotFound
  • RecordNotValid
  • ScopeNotDefined
  • StatementInvocationFailed
  • StatementNotValid
  • UnableToSetFetchMode

Functions

  • extract_charset_and_collate
  • get_model

Class RelationCollection

Relation collection of a model.

ICanBoogie\ActiveRecord\RelationCollection implements ArrayAccess uses ICanBoogie\Accessor\AccessorTrait (not available)
Namespace: ICanBoogie\ActiveRecord
Located at ActiveRecord/RelationCollection.php

Methods summary

protected
# get_model( )
public
# __construct( ICanBoogie\ActiveRecord\Model $model )

Initialize the ICanBoogie\ActiveRecord\RelationCollection::$model property.

Initialize the ICanBoogie\ActiveRecord\RelationCollection::$model property.

Parameters

$model
The parent model.
public boolean
# offsetExists( string $relation_name )

Checks if a relation exists.

Checks if a relation exists.

Parameters

$relation_name

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public ICanBoogie\ActiveRecord\Relation
# offsetGet( string $relation_name )

Returns a relation.

Returns a relation.

Parameters

$relation_name

Returns

ICanBoogie\ActiveRecord\Relation

Throws

ICanBoogie\ActiveRecord\RelationNotDefined
if the relation is not defined.

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( $relation_name, $relation )

Throws

ICanBoogie\OffsetNotWritable
because relations cannot be set.

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( $relation_name )

Throws

ICanBoogie\OffsetNotWritable
because relations cannot be unset.

Implementation of

ArrayAccess::offsetUnset()
public ICanBoogie\ActiveRecord\Model
# belongs_to( string|array $belongs_to )

Add a belongs to relation.

Add a belongs to relation.

$cars->belongs_to([ $drivers, $brands ]);
# or
$cars->belongs_to([ 'drivers', 'brands' ]);
# or
$cars->belongs_to($drivers, $brands);
# or
$cars->belongs_to($drivers)->belongs_to($brands);
# or
$cars->belongs_to([

    [ $drivers, [ 'local_key' => 'card_id', 'foreign_key' => 'driver_id' ] ]
    [ $brands, [ 'local_key' => 'brand_id', 'foreign_key' => 'brand_id' ] ]

]);

Parameters

$belongs_to

Returns

ICanBoogie\ActiveRecord\Model
public ICanBoogie\ActiveRecord\Model
# has_many( ICanBoogie\ActiveRecord\Model|string $related, array $options = [] )

Add a one-to-many relation.

Add a one-to-many relation.

$this->has_many('comments');
$this->has_many([ 'comments', 'attachments' ]);
$this->has_many([ [ 'comments', [ 'as' => 'comments' ] ], 'attachments' ]);

Parameters

$related

The related model can be specified using its instance or its identifier.

$options

the following options are available:

  • local_key: The name of the local key. Default: The parent model's primary key.
  • foreign_key: The name of the foreign key. Default: The parent model's primary key.
  • as: The name of the magic property to add to the prototype. Default: a plural name resolved from the foreign model's id.

Returns

ICanBoogie\ActiveRecord\Model

See

ICanBoogie\ActiveRecord\HasManyRelation

Properties summary

protected ICanBoogie\ActiveRecord\Model $model

Parent model.

Parent model.

#
protected ICanBoogie\ActiveRecord\Relation[] $relations

Relations.

Relations.

#

Magic properties

public read-only ICanBoogie\ActiveRecord\Model $model

The parent model.

ICanBoogie/ActiveRecord 3.0.x API documentation generated by ApiGen