com\setasign\SetaFramework\Database\JoinedTable
JoinedTable Class JoinedTable
File: /SetaFramework/src/Database/JoinedTable/JoinedTable.php
Class hierarchy
Implements
Summary
Constants
OPTION_COLUMNS
OPTION_MAGIC_COLUMNS
OPTION_METADATA_CACHE
OPTION_PRIMARY_KEY
OPTION_ROW_CLASS_NAME
OPTION_TABLE_NAMES
Properties
$columns
protected array<string, array<int, string|string[]>> JoinedTable::$columns
Available columns
$hiddenColumns
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()
public JoinedTable::__construct (
\com\setasign\SetaFramework\Database\Database $db,
\com\setasign\SetaFramework\Database\RowFactoryInterface $rowFactory,
?array $options = null
)\com\setasign\SetaFramework\Database\RowFactoryInterface $rowFactory,
?array $options = null
The constructor
Available Options:
| Option | Type | Description | SampleData |
|---|---|---|---|
| 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
createRow()
public JoinedTable::createRow (
array $data = array (
)
): \com\setasign\SetaFramework\Database\Table\RowParameters
- $data : array
find()
public JoinedTable::find (
int|string|array<string, mixed> $primaryKey,
?\com\setasign\SetaFramework\Database\Table\Row $row = null
): ?\com\setasign\SetaFramework\Database\Table\Row?\com\setasign\SetaFramework\Database\Table\Row $row = null
Returns the row for $primaryKey
Parameters
- $primaryKey : int|string|array<string, mixed>
- $row : ?\com\setasign\SetaFramework\Database\Table\Row
insert()
Insert a row into the table.
Parameters
- $data : array
Return Values
Returns the last inserted id
update()
Updates one or more rows in the table.
Parameters
- $data : array
- $where : null|string|callable
