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 checks( Yiisoft\Db\Constraint\Check $checks ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $checks | Yiisoft\Db\Constraint\Check |
The check constraints. |
public function checks(Check ...$checks): static;
Set metadata for a column specified.
| public abstract column( string $name, Yiisoft\Db\Schema\Column\ColumnInterface $column ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $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 columns( Yiisoft\Db\Schema\Column\ColumnInterface[] $columns ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $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 comment( string|null $comment ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $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 createSql( string|null $sql ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $sql | string|null | |
public function createSql(?string $sql): static;
Set default value constraints of this table.
| public abstract defaultValues( Yiisoft\Db\Constraint\DefaultValue $defaultValues ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $defaultValues | Yiisoft\Db\Constraint\DefaultValue |
The default value constraints. |
public function defaultValues(DefaultValue ...$defaultValues): static;
Set foreign key constraints of this table.
| public abstract foreignKeys( Yiisoft\Db\Constraint\ForeignKey $foreignKeys ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $foreignKeys | Yiisoft\Db\Constraint\ForeignKey |
The foreign key constraints. |
public function foreignKeys(ForeignKey ...$foreignKeys): static;
| public abstract getChecks( ): Yiisoft\Db\Constraint\Check[] | ||
| 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 getColumn( string $name ): Yiisoft\Db\Schema\Column\ColumnInterface|null | ||
| $name | string |
The column name. |
public function getColumn(string $name): ?ColumnInterface;
| public abstract getColumnNames( ): string[] | ||
| return | string[] |
The names of all columns in this table. |
|---|---|---|
public function getColumnNames(): array;
| public abstract getColumns( ): Yiisoft\Db\Schema\Column\ColumnInterface[] | ||
| return | Yiisoft\Db\Schema\Column\ColumnInterface[] |
The column metadata of this table. Array of 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 getComment( ): string|null |
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 getCreateSql( ): string|null |
public function getCreateSql(): ?string;
| public abstract getDefaultValues( ): Yiisoft\Db\Constraint\DefaultValue[] | ||
| return | Yiisoft\Db\Constraint\DefaultValue[] |
The default value constraints of this table. |
|---|---|---|
public function getDefaultValues(): array;
| public abstract getForeignKeys( ): Yiisoft\Db\Constraint\ForeignKey[] | ||
| 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 getFullName( ): string |
public function getFullName(): string;
Returns the index constraints of this table.
| public abstract getIndexes( ): Yiisoft\Db\Constraint\Index[] | ||
| 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 getFullName() to get the table name with the schema name.
| public abstract getName( ): string |
public function getName(): string;
Returns the options of this table.
| public abstract getOptions( ): string[] | ||
| return | string[] |
The options of this table. |
|---|---|---|
public function getOptions(): array;
| public abstract getPrimaryKey( ): string[] | ||
| return | string[] |
The primary key column names. |
|---|---|---|
public function getPrimaryKey(): array;
Returns the schema name that this table belongs to.
| public abstract getSchemaName( ): string |
public function getSchemaName(): string;
Return the sequence name for the primary key or null if no sequence.
| public abstract getSequenceName( ): string|null |
public function getSequenceName(): ?string;
Returns the unique indexes of this table.
| public abstract getUniques( ): Yiisoft\Db\Constraint\Index[] | ||
| return | Yiisoft\Db\Constraint\Index[] |
The unique indexes of this table. |
|---|---|---|
public function getUniques(): array;
Set indexes of this table.
| public abstract indexes( Yiisoft\Db\Constraint\Index $indexes ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $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 schemaName() to set the table schema name.
| public abstract name( string $name ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $name | string | |
public function name(string $name): static;
Set the options of this table.
| public abstract options( string $options ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $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 schemaName( string $schemaName ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $schemaName | string | |
public function schemaName(string $schemaName): static;
Set a sequence name for the primary key or null if no sequence.
| public abstract sequenceName( string|null $sequenceName ): Yiisoft\Db\Schema\TableSchemaInterface | ||
| $sequenceName | string|null | |
public function sequenceName(?string $sequenceName): static;
Signup or Login in order to comment.