Class Yiisoft\Db\Schema\TableSchema
| Inheritance | Yiisoft\Db\Schema\TableSchema |
|---|---|
| Implements | Yiisoft\Db\Schema\TableSchemaInterface |
Represents the metadata of a database table.
Public Methods
Method Details
| public __construct( string $name = '', string $schemaName = '' ): mixed | ||
| $name | string | |
| $schemaName | string | |
public function __construct(
private string $name = '',
private string $schemaName = '',
) {}
| public checks( Yiisoft\Db\Constraint\Check $checks ): Yiisoft\Db\Schema\TableSchema | ||
| $checks | Yiisoft\Db\Constraint\Check | |
public function checks(Check ...$checks): static
{
$this->checks = $checks;
return $this;
}
| public column( string $name, Yiisoft\Db\Schema\Column\ColumnInterface $column ): Yiisoft\Db\Schema\TableSchema | ||
| $name | string | |
| $column | Yiisoft\Db\Schema\Column\ColumnInterface | |
public function column(string $name, ColumnInterface $column): static
{
$this->columns[$name] = $column;
return $this;
}
| public columns( array $columns ): Yiisoft\Db\Schema\TableSchema | ||
| $columns | array | |
public function columns(array $columns): static
{
$this->columns = $columns;
return $this;
}
| public comment( string|null $comment ): Yiisoft\Db\Schema\TableSchema | ||
| $comment | string|null | |
public function comment(?string $comment): static
{
$this->comment = $comment;
return $this;
}
| public createSql( string|null $sql ): Yiisoft\Db\Schema\TableSchema | ||
| $sql | string|null | |
public function createSql(?string $sql): static
{
$this->createSql = $sql;
return $this;
}
| public defaultValues( Yiisoft\Db\Constraint\DefaultValue $defaultValues ): Yiisoft\Db\Schema\TableSchema | ||
| $defaultValues | Yiisoft\Db\Constraint\DefaultValue | |
public function defaultValues(DefaultValue ...$defaultValues): static
{
$this->defaultValues = $defaultValues;
return $this;
}
| public foreignKeys( Yiisoft\Db\Constraint\ForeignKey $foreignKeys ): Yiisoft\Db\Schema\TableSchema | ||
| $foreignKeys | Yiisoft\Db\Constraint\ForeignKey | |
public function foreignKeys(ForeignKey ...$foreignKeys): static
{
$this->foreignKeys = $foreignKeys;
return $this;
}
| public getColumn( string $name ): Yiisoft\Db\Schema\Column\ColumnInterface|null | ||
| $name | string | |
public function getColumn(string $name): ?ColumnInterface
{
return $this->columns[$name] ?? null;
}
| public getColumnNames( ): array |
public function getColumnNames(): array
{
return array_keys($this->columns);
}
| public getCreateSql( ): string|null |
public function getCreateSql(): ?string
{
return $this->createSql;
}
| public getDefaultValues( ): array |
public function getDefaultValues(): array
{
return $this->defaultValues;
}
| public getForeignKeys( ): array |
public function getForeignKeys(): array
{
return $this->foreignKeys;
}
| public getFullName( ): string |
public function getFullName(): string
{
if ($this->schemaName === '') {
return $this->name;
}
return "$this->schemaName.$this->name";
}
| public getPrimaryKey( ): array |
public function getPrimaryKey(): array
{
foreach ($this->indexes as $index) {
if ($index->isPrimaryKey) {
return $index->columnNames;
}
}
return array_keys(
array_filter(
$this->columns,
static fn(ColumnInterface $column) => $column->isPrimaryKey(),
),
);
}
| public getSchemaName( ): string |
public function getSchemaName(): string
{
return $this->schemaName;
}
| public getSequenceName( ): string|null |
public function getSequenceName(): ?string
{
return $this->sequenceName;
}
| public getUniques( ): array |
public function getUniques(): array
{
return array_filter($this->indexes, static fn(Index $index): bool => $index->isUnique);
}
| public indexes( Yiisoft\Db\Constraint\Index $indexes ): Yiisoft\Db\Schema\TableSchema | ||
| $indexes | Yiisoft\Db\Constraint\Index | |
public function indexes(Index ...$indexes): static
{
$this->indexes = $indexes;
return $this;
}
| public name( string $name ): Yiisoft\Db\Schema\TableSchema | ||
| $name | string | |
public function name(string $name): static
{
$this->name = $name;
return $this;
}
| public options( string $options ): Yiisoft\Db\Schema\TableSchema | ||
| $options | string | |
public function options(string ...$options): static
{
$this->options = $options;
return $this;
}
| public schemaName( string $schemaName ): Yiisoft\Db\Schema\TableSchema | ||
| $schemaName | string | |
public function schemaName(string $schemaName): static
{
$this->schemaName = $schemaName;
return $this;
}
| public sequenceName( string|null $sequenceName ): Yiisoft\Db\Schema\TableSchema | ||
| $sequenceName | string|null | |
public function sequenceName(?string $sequenceName): static
{
$this->sequenceName = $sequenceName;
return $this;
}
Signup or Login in order to comment.