com\setasign\SetaFramework\Database\Table
Table Class Table
File: /SetaFramework/src/Database/Table/Table.php
Class hierarchy
Implements
Summary
Constants
OPTION_COLUMNS
OPTION_MAGIC_COLUMNS
OPTION_METADATA_CACHE
OPTION_PRIMARY_KEY
OPTION_ROW_CLASS_NAME
OPTION_TABLE_NAME
Properties
$hiddenColumns
Columns which will not get exposed through the toArray() method of a table row
$magicColumns
protected array Table::$magicColumns
Available magic columns
$metadataCache
protected ?\Psr\SimpleCache\CacheInterface Table::$metadataCache
A cache object for storing table metadata
$primaryKey
protected array<string, string> Table::$primaryKey
Contains the primary key ['columnA' => 'tableA.columnA', 'columnB' => 'tableA.columnB']
$rowClassName
protected string Table::$rowClassName
The row class name
$tableName
protected string Table::$tableName
The table name
Methods
__construct()
public Table::__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 |
|---|---|---|---|
| tableName* | array | Contains all tableNames of the tables | ['tableA', 'tableB'] |
| rowClassName | string | Classname for the row objects of this table. | Row |
| columns | array | Contains all columns of the table | ['columnA', 'columnB'] |
| primaryKey | array | Contains the primary key; This shouldn't be wrong or incomplete. | ['columnA' => 'tableA.columnA', 'columnB' => 'tableA.columnB'] |
| 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`))] |
*required
Parameters
- $db : \com\setasign\SetaFramework\Database\Database
- $rowFactory : \com\setasign\SetaFramework\Database\RowFactoryInterface
- $options : ?array
Exceptions
Throws MissingPrimaryKeyException If a table doesn't have a primary key
find()
Returns a Table\Row object.
Parameters
- $primaryKey : int|string|array<string, mixed>
- $row : ?Row
If this is set and the primary key is set, the result data will put into this object.
Exceptions
Throws \InvalidArgumentException If one or more primary keys are missing
insertMultiple()
Insert multiple rows into the table.
Parameters
- $datas : array
All rows need the same columns!!
