Methods

Configures the relationship

__construct(string $from, string $name, array $config) 

Parameters

$from

string

the model that initiates the relationship

$name

string

name of the relationship

$config

array

config values like model_to classname, key_from /p>

Allow outside access to protected properties

__get($property) : 

Parameters

$property

Exceptions

\FuelException Invalid relation property

Returns

Takes the current relations and attempts to delete them when cascading is allowed or forced

delete(\Orm\Model $model_from, array | \Orm\Model $model_to, bool $parent_deleted, null | bool $cascade) 

Parameters

$model_from

\Orm\Model

instance of model_from

$model_to

array\Orm\Model

single or multiple model instances to delete

$parent_deleted

bool

whether the model_from has been saved already

$cascade

nullbool

either uses default setting (null) or forces when true or prevents when false

Should get the objects related to the given object by this relation

get(\Orm\Model $from) : object | array

Parameters

$from

Model

Returns

objectarray

Returns true if this relation is a singular relation.

is_singular() : bool

Eg, has_one not has_many

Returns

bool

Returns tables to join and fields to select with optional additional settings like order/where

join($alias_from, $rel_name, $alias_to) : array

Parameters

$alias_from

$rel_name

$alias_to

Returns

array

Should get the properties as associative array with alias => property, the table alias is given to be included with the property

select($table) : array

Parameters

$table

string

Returns

array

 Properties

 

<p>whether deleting this one's model_from should cascade to delete model_to</p>

$cascade_delete : bool

 

<p>whether saving this one's model_from should cascade to save model_to</p>

$cascade_save : bool

 

<p>where /p>

$conditions : array

 

<p>primary key of parent model</p>

$key_from : string

 

<p>foreign key in related model</p>

$key_to : string

 

<p>classname of the parent model</p>

$model_from : \Orm\Model

 

<p>classname of the related model</p>

$model_to : string

 

<p>name of the relationship in the model_from</p>

$name : string

 

<p>whether it's a single object or multiple</p>

$singular : bool