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 mixed __construct ( string $name = '', string $schemaName = '' ) | ||
| $name | string | |
| $schemaName | string | |
public function __construct(
private string $name = '',
private string $schemaName = '',
) {}
| public Yiisoft\Db\Schema\TableSchema checks ( Yiisoft\Db\Constraint\Check $checks ) | ||
| $checks | Yiisoft\Db\Constraint\Check | |
public function checks(Check ...$checks): static
{
$this->checks = $checks;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema column ( string $name, Yiisoft\Db\Schema\Column\ColumnInterface $column ) | ||
| $name | string | |
| $column | Yiisoft\Db\Schema\Column\ColumnInterface | |
public function column(string $name, ColumnInterface $column): static
{
$this->columns[$name] = $column;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema columns ( array $columns ) | ||
| $columns | array | |
public function columns(array $columns): static
{
$this->columns = $columns;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema comment ( string|null $comment ) | ||
| $comment | string|null | |
public function comment(?string $comment): static
{
$this->comment = $comment;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema createSql ( string|null $sql ) | ||
| $sql | string|null | |
public function createSql(?string $sql): static
{
$this->createSql = $sql;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema defaultValues ( Yiisoft\Db\Constraint\DefaultValue $defaultValues ) | ||
| $defaultValues | Yiisoft\Db\Constraint\DefaultValue | |
public function defaultValues(DefaultValue ...$defaultValues): static
{
$this->defaultValues = $defaultValues;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema foreignKeys ( Yiisoft\Db\Constraint\ForeignKey $foreignKeys ) | ||
| $foreignKeys | Yiisoft\Db\Constraint\ForeignKey | |
public function foreignKeys(ForeignKey ...$foreignKeys): static
{
$this->foreignKeys = $foreignKeys;
return $this;
}
| public Yiisoft\Db\Schema\Column\ColumnInterface|null getColumn ( string $name ) | ||
| $name | string | |
public function getColumn(string $name): ?ColumnInterface
{
return $this->columns[$name] ?? null;
}
| public array getColumnNames ( ) |
public function getColumnNames(): array
{
return array_keys($this->columns);
}
| public string|null getCreateSql ( ) |
public function getCreateSql(): ?string
{
return $this->createSql;
}
| public array getDefaultValues ( ) |
public function getDefaultValues(): array
{
return $this->defaultValues;
}
| public array getForeignKeys ( ) |
public function getForeignKeys(): array
{
return $this->foreignKeys;
}
| public string getFullName ( ) |
public function getFullName(): string
{
if ($this->schemaName === '') {
return $this->name;
}
return "$this->schemaName.$this->name";
}
| public array getPrimaryKey ( ) |
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 string getSchemaName ( ) |
public function getSchemaName(): string
{
return $this->schemaName;
}
| public string|null getSequenceName ( ) |
public function getSequenceName(): ?string
{
return $this->sequenceName;
}
| public array getUniques ( ) |
public function getUniques(): array
{
return array_filter($this->indexes, static fn(Index $index): bool => $index->isUnique);
}
| public Yiisoft\Db\Schema\TableSchema indexes ( Yiisoft\Db\Constraint\Index $indexes ) | ||
| $indexes | Yiisoft\Db\Constraint\Index | |
public function indexes(Index ...$indexes): static
{
$this->indexes = $indexes;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema name ( string $name ) | ||
| $name | string | |
public function name(string $name): static
{
$this->name = $name;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema options ( string $options ) | ||
| $options | string | |
public function options(string ...$options): static
{
$this->options = $options;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema schemaName ( string $schemaName ) | ||
| $schemaName | string | |
public function schemaName(string $schemaName): static
{
$this->schemaName = $schemaName;
return $this;
}
| public Yiisoft\Db\Schema\TableSchema sequenceName ( string|null $sequenceName ) | ||
| $sequenceName | string|null | |
public function sequenceName(?string $sequenceName): static
{
$this->sequenceName = $sequenceName;
return $this;
}
Signup or Login in order to comment.