com\setasign\SetaFramework\Database\JoinedTable

JoinedTable Class JoinedTable

File: /SetaFramework/src/Database/JoinedTable/JoinedTable.php

Class hierarchy

Implements

Summary

Constants

OPTION_COLUMNS

public const JoinedTable::OPTION_COLUMNS = 'columns'

OPTION_MAGIC_COLUMNS

public const JoinedTable::OPTION_MAGIC_COLUMNS = 'magicColumns'

OPTION_METADATA_CACHE

public const JoinedTable::OPTION_METADATA_CACHE = 'metadataCache'

OPTION_PRIMARY_KEY

public const JoinedTable::OPTION_PRIMARY_KEY = 'primaryKey'

OPTION_ROW_CLASS_NAME

public const JoinedTable::OPTION_ROW_CLASS_NAME = 'rowClassName'

OPTION_TABLE_NAMES

public const JoinedTable::OPTION_TABLE_NAMES = 'tableNames'

Properties

$columns

protected array<string, array<int, string|string[]>> JoinedTable::$columns

Available columns

$hiddenColumns

protected array JoinedTable::$hiddenColumns = array()

Columns which will not get exposed through the toArray() method of a table row

$magicColumns

protected array JoinedTable::$magicColumns

Available magic columns

$metadataCache

protected ?\Psr\SimpleCache\CacheInterface JoinedTable::$metadataCache

A cache object for storing table metadata

$primaryKey

protected array JoinedTable::$primaryKey

The primary key

$rowClassName

protected string JoinedTable::$rowClassName

The row class name

$tableNames

protected array JoinedTable::$tableNames

Table names


Methods

__construct()

The constructor

Available Options:

OptionTypeDescriptionSampleData
tableNames array[] Contains all tableNames of the joined tables array('tableA', 'tableB')
rowClassName string Classname for the row objects of this table. \com\setasign\SetaFramework\Database\Table\Row
columns array[] Contains all columns of the table array('tableA' => array('columnA', 'columnB'),[..])
primaryKey array[] Contains the primary key array('columnA' => 'tableA.columnA')
metadataCache \Psr\SimpleCache\CacheInterface Cache-object for metadata -
magicColumns array Contains special columns that are read only and can use Expression. ['Name' => new Expression('concat(`firstname`, ' ', `lastname`))]

The option tableNames is needed.

Parameters
$db : \com\setasign\SetaFramework\Database\Database
 
$rowFactory : \com\setasign\SetaFramework\Database\RowFactoryInterface
 
$options : ?array
 
Exceptions

Throws \InvalidArgumentException If tableNames isn't set

Throws \com\setasign\SetaFramework\Database\Table\MissingPrimaryKeyException If a table doesn't have a primary key

__sleep()

public JoinedTable::__sleep (
void
): void

createRow()

Parameters
$data : array
 

delete()

public JoinedTable::delete (
string|callable $where
): void

Delete from the database table

Parameters
$where : string|callable
 

find()

public JoinedTable::find (
int|string|array<string, mixed> $primaryKey,
?\com\setasign\SetaFramework\Database\Table\Row $row = null
): ?\com\setasign\SetaFramework\Database\Table\Row

Returns the row for $primaryKey

Parameters
$primaryKey : int|string|array<string, mixed>
 
$row : ?\com\setasign\SetaFramework\Database\Table\Row
 

getColumns()

public JoinedTable::getColumns (
bool $groupedByTable = false
): array

Get all column names

Parameters
$groupedByTable : bool
 

getDb()

Returns the datanase instance

getHiddenColumns()

public JoinedTable::getHiddenColumns (
void
): array

Get all hidden columns

getMagicColumns()

public JoinedTable::getMagicColumns (
void
): array

Return all magic columns of the table

getPrimaryKey()

public JoinedTable::getPrimaryKey (
void
): array

Get the primary key columns

getRowClassName()

public JoinedTable::getRowClassName (
void
): string

Get the row class name

getSelect()

Get a prepared select query for this table

getTableNames()

public JoinedTable::getTableNames (
void
): array

Returns the names of all tables which joined in this table

insert()

public JoinedTable::insert (
array $data
): int

Insert a row into the table.

Parameters
$data : array
 
Return Values

Returns the last inserted id

update()

public JoinedTable::update (
array $data,
null|string|callable $where = null
): void

Updates one or more rows in the table.

Parameters
$data : array
 
$where : null|string|callable