PHP Class atk4\data\Join

Inheritance: use trait atk4\core\TrackableTrait, use trait atk4\core\InitializerTrait
Show file Open project: atk4/data

Protected Properties

Property Type Description
$foreign_field Field to be used for matching in a foreign table. By default it's 'id'.
$foreign_table For SQL, This can also be an expression or sub-select.
$id ID used by a joined table.
$id_field When deleting record, this field will be conditioned. ->where($join->id_field, $join->id)->delete();
$join When join is done on another join.
$master_field Field to be used for matching inside master field. By default it's $foreign_table.'_id'.
$persistence If $persistence is set, then it's used for loading and storing the values, instead $owner->persistence.
$prefix When $prefix is set, then all the fields generated through our wrappers will be automatically prefixed inside the model.
$reverse If you are using the following syntax: $user->join('contact','default_contact_id'); Then the ID connecting tables is stored in foreign table and the order of saving and delete needs to be reversed. In this case $reverse will be set to true. You can specify value of this property.
$save_buffer Data which is populated here as the save/insert progresses.
$weak Is our join weak? Weak join will stop you from touching foreign table.

Public Methods

Method Description
__construct ( $defaults = [] ) default constructor. Will copy argument into properties.
_init ( )
add ( $object, $defaults = [] )
addField ( $n, $defaults = [] ) Adding field into join will automatically associate that field with this join. That means it won't be loaded from $table, but form the join instead.
addFields ( $fields = [] )
afterUnload ( )
containsMany ( $model, $defaults = [] ) wrapper for containsMany that will associate field with join.
containsOne ( $model, $defaults = [] ) wrapper for containsOne that will associate field with join.
getDesiredName ( ) Will use either foreign_alias or create #join_.
hasMany ( $model, $defaults = [] ) creates reference based on the field from the join.
hasOne ( $model, $defaults = [] ) creates reference based on a field from the join.
importModel ( $m, $defaults = [] ) Will iterate through this model by pulling - fields - references - conditions.
init ( )
join ( $foreign_table, $defaults = [] ) Join will be attached to a current join.
leftJoin ( $foreign_table, $defaults = [] )
set ( $field, $value )
weakJoin ( $defaults = [] ) weakJoin will be attached to a current join.
weakJoinModel ( $model, $fields = [] ) Joins with the primary table of the model and then import all of the data into our model.

Method Details

__construct() public method

default constructor. Will copy argument into properties.
public __construct ( $defaults = [] )

_init() public method

public _init ( )

add() public method

public add ( $object, $defaults = [] )

addField() public method

Adding field into join will automatically associate that field with this join. That means it won't be loaded from $table, but form the join instead.
public addField ( $n, $defaults = [] )

addFields() public method

public addFields ( $fields = [] )

afterUnload() public method

public afterUnload ( )

containsMany() public method

wrapper for containsMany that will associate field with join.
public containsMany ( $model, $defaults = [] )

containsOne() public method

wrapper for containsOne that will associate field with join.
public containsOne ( $model, $defaults = [] )

getDesiredName() public method

Will use either foreign_alias or create #join_.
public getDesiredName ( )

hasMany() public method

creates reference based on the field from the join.
public hasMany ( $model, $defaults = [] )

hasOne() public method

creates reference based on a field from the join.
public hasOne ( $model, $defaults = [] )

importModel() public method

and then will apply them locally. Any you think that any fields could clash, then use ['prefix'=>'m2'] which will be pre-pended to all the fields. Conditions will me automatically mapped.
public importModel ( $m, $defaults = [] )

init() public method

public init ( )

join() public method

Join will be attached to a current join.
public join ( $foreign_table, $defaults = [] )

leftJoin() public method

public leftJoin ( $foreign_table, $defaults = [] )

set() public method

public set ( $field, $value )

weakJoin() public method

weakJoin will be attached to a current join.
public weakJoin ( $defaults = [] )

weakJoinModel() public method

Joins with the primary table of the model and then import all of the data into our model.
public weakJoinModel ( $model, $fields = [] )

Property Details

$foreign_field protected property

Field to be used for matching in a foreign table. By default it's 'id'.
protected $foreign_field

$foreign_table protected property

For SQL, This can also be an expression or sub-select.
protected $foreign_table

$id protected property

ID used by a joined table.
protected $id

$id_field protected property

When deleting record, this field will be conditioned. ->where($join->id_field, $join->id)->delete();
protected $id_field

$join protected property

When join is done on another join.
protected $join

$master_field protected property

Field to be used for matching inside master field. By default it's $foreign_table.'_id'.
protected $master_field

$persistence protected property

If $persistence is set, then it's used for loading and storing the values, instead $owner->persistence.
protected $persistence

$prefix protected property

When $prefix is set, then all the fields generated through our wrappers will be automatically prefixed inside the model.
protected $prefix

$reverse protected property

If you are using the following syntax: $user->join('contact','default_contact_id'); Then the ID connecting tables is stored in foreign table and the order of saving and delete needs to be reversed. In this case $reverse will be set to true. You can specify value of this property.
protected $reverse

$save_buffer protected property

Data which is populated here as the save/insert progresses.
protected $save_buffer

$weak protected property

Is our join weak? Weak join will stop you from touching foreign table.
protected $weak