Interface Yiisoft\Db\Schema\TableSchemaInterface
| Implemented by | Yiisoft\Db\Schema\TableSchema |
|---|
Represents the metadata of a database table.
It defines a set of methods to retrieve the table name, schema name, column names, primary key, foreign keys, etc.
The information is obtained from the database schema and may vary according to the DBMS type.
Public Methods
Method Details
Set check constraints of this table.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface checks ( Yiisoft\Db\Constraint\Check $checks ) | ||
| $checks | Yiisoft\Db\Constraint\Check |
The check constraints. |
public function checks(Check ...$checks): static;
Set metadata for a column specified.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface column ( string $name, Yiisoft\Db\Schema\Column\ColumnInterface $column ) | ||
| $name | string |
The column name. |
| $column | Yiisoft\Db\Schema\Column\ColumnInterface | |
public function column(string $name, ColumnInterface $column): static;
Set metadata for multiple columns.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface columns ( Yiisoft\Db\Schema\Column\ColumnInterface[] $columns ) | ||
| $columns | Yiisoft\Db\Schema\Column\ColumnInterface[] |
The columns metadata indexed by column names. |
public function columns(array $columns): static;
Set the comment of the table or null if there is no comment.
Not all DBMS support this.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface comment ( string|null $comment ) | ||
| $comment | string|null | |
public function comment(?string $comment): static;
Set SQL for creating this table, empty string if it is not found, or null if it is not initialized.
Supported by MySQL and Oracle DBMS.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface createSql ( string|null $sql ) | ||
| $sql | string|null | |
public function createSql(?string $sql): static;
Set default value constraints of this table.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface defaultValues ( Yiisoft\Db\Constraint\DefaultValue $defaultValues ) | ||
| $defaultValues | Yiisoft\Db\Constraint\DefaultValue |
The default value constraints. |
public function defaultValues(DefaultValue ...$defaultValues): static;
Set foreign key constraints of this table.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface foreignKeys ( Yiisoft\Db\Constraint\ForeignKey $foreignKeys ) | ||
| $foreignKeys | Yiisoft\Db\Constraint\ForeignKey |
The foreign key constraints. |
public function foreignKeys(ForeignKey ...$foreignKeys): static;
| public abstract Yiisoft\Db\Constraint\Check[] getChecks ( ) | ||
| return | Yiisoft\Db\Constraint\Check[] |
The check constraints of this table. |
|---|---|---|
public function getChecks(): array;
Returns the named column metadata or null if the named column does not exist.
| public abstract Yiisoft\Db\Schema\Column\ColumnInterface|null getColumn ( string $name ) | ||
| $name | string |
The column name. |
public function getColumn(string $name): ?ColumnInterface;
| public abstract string[] getColumnNames ( ) | ||
| return | string[] |
The names of all columns in this table. |
|---|---|---|
public function getColumnNames(): array;
| public abstract Yiisoft\Db\Schema\Column\ColumnInterface[] getColumns ( ) | ||
| return | Yiisoft\Db\Schema\Column\ColumnInterface[] |
The column metadata of this table. Array of {@see \Yiisoft\Db\Schema\Column\ColumnInterface} objects indexed by column names. |
|---|---|---|
public function getColumns(): array;
Returns the comment of the table or null if no comment.
| public abstract string|null getComment ( ) |
public function getComment(): ?string;
Returns SQL for create this table, empty string if it is not found, or null if it is not initialized.
Supported by MySQL and Oracle DBMS.
| public abstract string|null getCreateSql ( ) |
public function getCreateSql(): ?string;
| public abstract Yiisoft\Db\Constraint\DefaultValue[] getDefaultValues ( ) | ||
| return | Yiisoft\Db\Constraint\DefaultValue[] |
The default value constraints of this table. |
|---|---|---|
public function getDefaultValues(): array;
| public abstract Yiisoft\Db\Constraint\ForeignKey[] getForeignKeys ( ) | ||
| return | Yiisoft\Db\Constraint\ForeignKey[] |
The foreign key constraints of this table. |
|---|---|---|
public function getForeignKeys(): array;
Returns the full name of this table including the schema name.
| public abstract string getFullName ( ) |
public function getFullName(): string;
Returns the index constraints of this table.
| public abstract Yiisoft\Db\Constraint\Index[] getIndexes ( ) | ||
| return | Yiisoft\Db\Constraint\Index[] |
The index constraints of this table. |
|---|---|---|
public function getIndexes(): array;
Returns the table name. The schema name is not included. Use {@see getFullName()} to get the table name with the schema name.
| public abstract string getName ( ) |
public function getName(): string;
Returns the options of this table.
| public abstract string[] getOptions ( ) | ||
| return | string[] |
The options of this table. |
|---|---|---|
public function getOptions(): array;
| public abstract string[] getPrimaryKey ( ) | ||
| return | string[] |
The primary key column names. |
|---|---|---|
public function getPrimaryKey(): array;
Returns the schema name that this table belongs to.
| public abstract string getSchemaName ( ) |
public function getSchemaName(): string;
Return the sequence name for the primary key or null if no sequence.
| public abstract string|null getSequenceName ( ) |
public function getSequenceName(): ?string;
Returns the unique indexes of this table.
| public abstract Yiisoft\Db\Constraint\Index[] getUniques ( ) | ||
| return | Yiisoft\Db\Constraint\Index[] |
The unique indexes of this table. |
|---|---|---|
public function getUniques(): array;
Set indexes of this table.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface indexes ( Yiisoft\Db\Constraint\Index $indexes ) | ||
| $indexes | Yiisoft\Db\Constraint\Index |
The indexes. |
public function indexes(Index ...$indexes): static;
Set the name of this table.
The schema name must not be included. Use {@see \Yiisoft\Db\Schema\schemaName()} to set the table schema name.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface name ( string $name ) | ||
| $name | string | |
public function name(string $name): static;
Set the options of this table.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface options ( string $options ) | ||
| $options | string |
The options. |
public function options(string ...$options): static;
Set the name of the schema that this table belongs to or empty string for the default schema.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface schemaName ( string $schemaName ) | ||
| $schemaName | string | |
public function schemaName(string $schemaName): static;
Set a sequence name for the primary key or null if no sequence.
| public abstract Yiisoft\Db\Schema\TableSchemaInterface sequenceName ( string|null $sequenceName ) | ||
| $sequenceName | string|null | |
public function sequenceName(?string $sequenceName): static;
Signup or Login in order to comment.