Pionia Core

JoinContract

Table of Contents

Properties

$defaultJoinType  : JoinType
$joinAliases  : array<string|int, mixed>|null
$joins  : array<string|int, mixed>|null
$joinTypes  : array<string|int, mixed>|null

Methods

attachJoins()  : Join
Attaches all defined joins to the base query.
getAllItemsJoined()  : array<string|int, mixed>
Will be used when we are listing everything.
getOneJoined()  : object|null
Will be used when we are getting a single item.
joinQuery()  : Join
Resolve the base query to base on to start joining.
switchJoin()  : Join
weShouldJoin()  : bool
Detects whether to enter to enter the join mode or stay in the normal mode.

Properties

$defaultJoinType

public JoinType $defaultJoinType = \Pionia\Http\Services\JoinType::INNER

The default join type to use when joining tables.

$joinAliases

public array<string|int, mixed>|null $joinAliases = null

An associative array of aliases to be used for joins with the table in the service. The key is the table name and the value is the alias.

Tags
example
[
   'student' => 's',
]

This will join the student table using the alias s.

$joins

public array<string|int, mixed>|null $joins = null

An associative array of tables to be used for joins with the table in the service. The key is the table name and the value is an array of the columns to join on.

Tags
example
[
   'student' => ['id' => 'student_id'],
]

This will join the student table on the id column of the current table and the student_id column of the student table.

$joinTypes

public array<string|int, mixed>|null $joinTypes = null

An associative array of join types to be used for joins with the table in the service. The key is the table name and the value is the join type.

Tags
example
[
   'student' => JoinType::INNER,
]

This will join the student table using an inner join.

Methods

attachJoins()

Attaches all defined joins to the base query.

private attachJoins([Join|null $join = null ]) : Join
Parameters
$join : Join|null = null
Tags
throws
Exception
Return values
Join

getAllItemsJoined()

Will be used when we are listing everything.

private getAllItemsJoined() : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

getOneJoined()

Will be used when we are getting a single item.

private getOneJoined() : object|null
Tags
throws
Exception
Return values
object|null

joinQuery()

Resolve the base query to base on to start joining.

private joinQuery() : Join

If the developer has not yet defined any joins, we drop it and generate a new one.

Tags
throws
Exception
Return values
Join

switchJoin()

private switchJoin(JoinType $joinType, Join $query, string $table) : Join
Parameters
$joinType : JoinType

The type of join to use

$query : Join

The current query we are joining to

$table : string

The table to join

Return values
Join

The query with the join added

weShouldJoin()

Detects whether to enter to enter the join mode or stay in the normal mode.

private weShouldJoin() : bool

Normal mode queries one table at a time.

Return values
bool

        
On this page

Search results