PHP Class atk4\data\Reference_SQL_One

Inheritance: extends Reference_One
Show file Open project: atk4/data

Public Methods

Method Description
addField ( string | Field | array $field, string | null $their_field = null ) : Field_SQL_Expression Creates expression which sub-selects a field inside related model.
addFields ( array $fields = [], $defaults = [] ) Add multiple expressions by calling addField several times. Fields may contain 3 types of elements:.
addTitle ( array $defaults = [] ) : Field_SQL_Expression Add a title of related entity as expression to our field.
ref ( $defaults = [] )
refLink ( ) : Model Creates model that can be used for generating sub-query actions.
withTitle ( array $defaults = [] ) Add a title of related entity as expression to our field.

Method Details

addField() public method

Returns Expression in case you want to do something else with it.
public addField ( string | Field | array $field, string | null $their_field = null ) : Field_SQL_Expression
$field string | Field | array or [$field, ..defaults]
$their_field string | null
return Field_SQL_Expression

addFields() public method

[ 'name', 'surname' ] - will import those fields as-is [ 'full_name' => 'name', 'day_of_birth' => ['dob', 'type'=>'date'] ] - use alias and options [ ['dob', 'type' => 'date'] ] - use options You may also use second param to specify parameters: addFields(['from', 'to'], ['type' => 'date']);
public addFields ( array $fields = [], $defaults = [] )
$fields array

addTitle() public method

$order->hasOne('user_id', 'User')->addTitle(); This will add expression 'user' equal to ref('user_id')['name']; This method returns newly created expression field.
public addTitle ( array $defaults = [] ) : Field_SQL_Expression
$defaults array Properties
return Field_SQL_Expression

ref() public method

public ref ( $defaults = [] )

withTitle() public method

$order->hasOne('user_id', 'User')->addTitle(); This will add expression 'user' equal to ref('user_id')['name'];
public withTitle ( array $defaults = [] )
$defaults array Properties