Table
extends AbstractAsset
in package
Object Representation of a table.
Table of Contents
- $_columns : array<string|int, Column>
- $_fkConstraints : array<string|int, ForeignKeyConstraint>
- $_indexes : array<string|int, Index>
- $_name : string
- $_namespace : string|null
- Namespace of the asset. If none isset the default namespace is assumed.
- $_options : array<string|int, mixed>
- $_primaryKeyName : string|null
- $_quoted : bool
- $_schemaConfig : SchemaConfig|null
- $uniqueConstraints : array<string|int, UniqueConstraint>
- $implicitIndexes : array<string|int, Index>
- __clone() : void
- Clone of a Table triggers a deep clone of all affected assets.
- __construct() : mixed
- addColumn() : Column
- addForeignKeyConstraint() : self
- Adds a foreign key constraint.
- addIndex() : self
- addOption() : self
- addUniqueConstraint() : self
- addUniqueIndex() : self
- changeColumn() : self
- Change Column Details.
- columnsAreIndexed() : bool
- Checks if an index begins in the order of the given columns.
- dropColumn() : self
- Drops a Column from the Table.
- dropIndex() : void
- Drops an index from this table.
- dropPrimaryKey() : void
- Drops the primary key from this table.
- getColumn() : Column
- Returns the Column with the given name.
- getColumns() : array<string|int, Column>
- Returns ordered list of columns (primary keys are first, then foreign keys, then the rest)
- getComment() : string|null
- getForeignKey() : ForeignKeyConstraint
- Returns the foreign key constraint with the given name.
- getForeignKeyColumns() : array<string|int, Column>
- Returns the foreign key columns
- getForeignKeys() : array<string|int, ForeignKeyConstraint>
- Returns the foreign key constraints.
- getFullQualifiedName() : string
- The normalized name is full-qualified and lower-cased. Lower-casing is actually wrong, but we have to do it to keep our sanity. If you are using database objects that only differentiate in the casing (FOO vs Foo) then you will NOT be able to use Doctrine Schema abstraction.
- getIndex() : Index
- Returns the Index with the given name.
- getIndexes() : array<string|int, Index>
- getName() : string
- Returns the name of this schema asset.
- getNamespaceName() : string|null
- Gets the namespace name of this asset.
- getOption() : mixed
- getOptions() : array<string|int, mixed>
- getPrimaryKey() : Index|null
- Returns the primary key.
- getPrimaryKeyColumns() : array<string|int, Column>
- Returns the primary key columns.
- getQuotedName() : string
- Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.
- getShortestName() : string
- The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
- getUniqueConstraint() : UniqueConstraint
- Returns the unique constraint with the given name.
- getUniqueConstraints() : array<string|int, UniqueConstraint>
- Returns the unique constraints.
- hasColumn() : bool
- Returns whether this table has a Column with the given name.
- hasForeignKey() : bool
- Returns whether this table has a foreign key constraint with the given name.
- hasIndex() : bool
- Returns whether this table has an Index with the given name.
- hasOption() : bool
- hasPrimaryKey() : bool
- Returns whether this table has a primary key.
- hasUniqueConstraint() : bool
- Returns whether this table has a unique constraint with the given name.
- isInDefaultNamespace() : bool
- Is this asset in the default namespace?
- isQuoted() : bool
- Checks if this asset's name is quoted.
- removeForeignKey() : void
- Removes the foreign key constraint with the given name.
- removeUniqueConstraint() : void
- Removes the unique constraint with the given name.
- renameIndex() : self
- Renames an index.
- setComment() : self
- setPrimaryKey() : self
- Sets the Primary Key.
- setSchemaConfig() : void
- visit() : void
- _addColumn() : void
- _addForeignKeyConstraint() : self
- _addIndex() : self
- Adds an index to the table.
- _addUniqueConstraint() : self
- _generateIdentifierName() : string
- Generates an identifier from a list of column names obeying a certain string length.
- _getMaxIdentifierLength() : int
- _setName() : void
- Sets the name of this asset.
- isIdentifierQuoted() : bool
- Checks if this identifier is quoted.
- trimQuotes() : string
- Trim quotes from the identifier.
- _createIndex() : Index
- _createUniqueConstraint() : UniqueConstraint
- filterColumns() : array<string|int, Column>
- Returns only columns that have specified names
- normalizeIdentifier() : string
- Normalizes a given identifier.
Properties
$_columns
protected
array<string|int, Column>
$_columns
= []
$_fkConstraints
protected
array<string|int, ForeignKeyConstraint>
$_fkConstraints
= []
$_indexes
protected
array<string|int, Index>
$_indexes
= []
$_name
protected
string
$_name
= ''
$_namespace
Namespace of the asset. If none isset the default namespace is assumed.
protected
string|null
$_namespace
$_options
protected
array<string|int, mixed>
$_options
= ['create_options' => []]
$_primaryKeyName
protected
string|null
$_primaryKeyName
$_quoted
protected
bool
$_quoted
= false
$_schemaConfig
protected
SchemaConfig|null
$_schemaConfig
$uniqueConstraints
protected
array<string|int, UniqueConstraint>
$uniqueConstraints
= []
$implicitIndexes
private
array<string|int, Index>
$implicitIndexes
= []
Methods
__clone()
Clone of a Table triggers a deep clone of all affected assets.
public
__clone() : void
Return values
void —__construct()
public
__construct(string $name[, array<string|int, Column> $columns = [] ][, array<string|int, Index> $indexes = [] ][, array<string|int, UniqueConstraint> $uniqueConstraints = [] ][, array<string|int, ForeignKeyConstraint> $fkConstraints = [] ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $name : string
- $columns : array<string|int, Column> = []
- $indexes : array<string|int, Index> = []
- $uniqueConstraints : array<string|int, UniqueConstraint> = []
- $fkConstraints : array<string|int, ForeignKeyConstraint> = []
- $options : array<string|int, mixed> = []
Tags
Return values
mixed —addColumn()
public
addColumn(string $name, string $typeName[, array<string|int, mixed> $options = [] ]) : Column
Parameters
- $name : string
- $typeName : string
- $options : array<string|int, mixed> = []
Tags
Return values
Column —addForeignKeyConstraint()
Adds a foreign key constraint.
public
addForeignKeyConstraint(Table|string $foreignTable, array<string|int, string> $localColumnNames, array<string|int, string> $foreignColumnNames[, array<string|int, mixed> $options = [] ][, string|null $name = null ]) : self
Name is inferred from the local columns.
Parameters
- $foreignTable : Table|string
-
Table schema instance or table name
- $localColumnNames : array<string|int, string>
- $foreignColumnNames : array<string|int, string>
- $options : array<string|int, mixed> = []
- $name : string|null = null
Tags
Return values
self —addIndex()
public
addIndex(array<string|int, string> $columnNames[, string|null $indexName = null ][, array<string|int, string> $flags = [] ][, array<string|int, mixed> $options = [] ]) : self
Parameters
- $columnNames : array<string|int, string>
- $indexName : string|null = null
- $flags : array<string|int, string> = []
- $options : array<string|int, mixed> = []
Tags
Return values
self —addOption()
public
addOption(string $name, mixed $value) : self
Parameters
- $name : string
- $value : mixed
Return values
self —addUniqueConstraint()
public
addUniqueConstraint(array<string|int, string> $columnNames[, string|null $indexName = null ][, array<string|int, string> $flags = [] ][, array<string|int, mixed> $options = [] ]) : self
Parameters
- $columnNames : array<string|int, string>
- $indexName : string|null = null
- $flags : array<string|int, string> = []
- $options : array<string|int, mixed> = []
Return values
self —addUniqueIndex()
public
addUniqueIndex(array<string|int, string> $columnNames[, string|null $indexName = null ][, array<string|int, mixed> $options = [] ]) : self
Parameters
- $columnNames : array<string|int, string>
- $indexName : string|null = null
- $options : array<string|int, mixed> = []
Tags
Return values
self —changeColumn()
Change Column Details.
public
changeColumn(string $name, array<string|int, mixed> $options) : self
Parameters
- $name : string
- $options : array<string|int, mixed>
Tags
Return values
self —columnsAreIndexed()
Checks if an index begins in the order of the given columns.
public
columnsAreIndexed(array<string|int, string> $columnNames) : bool
Parameters
- $columnNames : array<string|int, string>
Return values
bool —dropColumn()
Drops a Column from the Table.
public
dropColumn(string $name) : self
Parameters
- $name : string
Return values
self —dropIndex()
Drops an index from this table.
public
dropIndex(string $name) : void
Parameters
- $name : string
-
The index name.
Tags
Return values
void —dropPrimaryKey()
Drops the primary key from this table.
public
dropPrimaryKey() : void
Tags
Return values
void —getColumn()
Returns the Column with the given name.
public
getColumn(string $name) : Column
Parameters
- $name : string
-
The column name.
Tags
Return values
Column —getColumns()
Returns ordered list of columns (primary keys are first, then foreign keys, then the rest)
public
getColumns() : array<string|int, Column>
Return values
array<string|int, Column> —getComment()
public
getComment() : string|null
Return values
string|null —getForeignKey()
Returns the foreign key constraint with the given name.
public
getForeignKey(string $name) : ForeignKeyConstraint
Parameters
- $name : string
-
The constraint name.
Tags
Return values
ForeignKeyConstraint —getForeignKeyColumns()
Returns the foreign key columns
public
getForeignKeyColumns() : array<string|int, Column>
Return values
array<string|int, Column> —getForeignKeys()
Returns the foreign key constraints.
public
getForeignKeys() : array<string|int, ForeignKeyConstraint>
Return values
array<string|int, ForeignKeyConstraint> —getFullQualifiedName()
The normalized name is full-qualified and lower-cased. Lower-casing is actually wrong, but we have to do it to keep our sanity. If you are using database objects that only differentiate in the casing (FOO vs Foo) then you will NOT be able to use Doctrine Schema abstraction.
public
getFullQualifiedName(string $defaultNamespaceName) : string
Every non-namespaced element is prefixed with the default namespace name which is passed as argument to this method.
Parameters
- $defaultNamespaceName : string
Tags
Return values
string —getIndex()
Returns the Index with the given name.
public
getIndex(string $name) : Index
Parameters
- $name : string
-
The index name.
Tags
Return values
Index —getIndexes()
public
getIndexes() : array<string|int, Index>
Return values
array<string|int, Index> —getName()
Returns the name of this schema asset.
public
getName() : string
Return values
string —getNamespaceName()
Gets the namespace name of this asset.
public
getNamespaceName() : string|null
If NULL is returned this means the default namespace is used.
Return values
string|null —getOption()
public
getOption(string $name) : mixed
Parameters
- $name : string
Return values
mixed —getOptions()
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPrimaryKey()
Returns the primary key.
public
getPrimaryKey() : Index|null
Return values
Index|null —The primary key, or null if this Table has no primary key.
getPrimaryKeyColumns()
Returns the primary key columns.
public
getPrimaryKeyColumns() : array<string|int, Column>
Tags
Return values
array<string|int, Column> —getQuotedName()
Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.
public
getQuotedName(AbstractPlatform $platform) : string
Parameters
- $platform : AbstractPlatform
Return values
string —getShortestName()
The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
public
getShortestName(string|null $defaultNamespaceName) : string
Parameters
- $defaultNamespaceName : string|null
Return values
string —getUniqueConstraint()
Returns the unique constraint with the given name.
public
getUniqueConstraint(string $name) : UniqueConstraint
Parameters
- $name : string
Tags
Return values
UniqueConstraint —getUniqueConstraints()
Returns the unique constraints.
public
getUniqueConstraints() : array<string|int, UniqueConstraint>
Return values
array<string|int, UniqueConstraint> —hasColumn()
Returns whether this table has a Column with the given name.
public
hasColumn(string $name) : bool
Parameters
- $name : string
-
The column name.
Return values
bool —hasForeignKey()
Returns whether this table has a foreign key constraint with the given name.
public
hasForeignKey(string $name) : bool
Parameters
- $name : string
Return values
bool —hasIndex()
Returns whether this table has an Index with the given name.
public
hasIndex(string $name) : bool
Parameters
- $name : string
-
The index name.
Return values
bool —hasOption()
public
hasOption(string $name) : bool
Parameters
- $name : string
Return values
bool —hasPrimaryKey()
Returns whether this table has a primary key.
public
hasPrimaryKey() : bool
Return values
bool —hasUniqueConstraint()
Returns whether this table has a unique constraint with the given name.
public
hasUniqueConstraint(string $name) : bool
Parameters
- $name : string
Return values
bool —isInDefaultNamespace()
Is this asset in the default namespace?
public
isInDefaultNamespace(string $defaultNamespaceName) : bool
Parameters
- $defaultNamespaceName : string
Return values
bool —isQuoted()
Checks if this asset's name is quoted.
public
isQuoted() : bool
Return values
bool —removeForeignKey()
Removes the foreign key constraint with the given name.
public
removeForeignKey(string $name) : void
Parameters
- $name : string
-
The constraint name.
Tags
Return values
void —removeUniqueConstraint()
Removes the unique constraint with the given name.
public
removeUniqueConstraint(string $name) : void
Parameters
- $name : string
Tags
Return values
void —renameIndex()
Renames an index.
public
renameIndex(string $oldName[, string|null $newName = null ]) : self
Parameters
- $oldName : string
-
The name of the index to rename from.
- $newName : string|null = null
-
The name of the index to rename to. If null is given, the index name will be auto-generated.
Tags
Return values
self —This table instance.
setComment()
public
setComment(string|null $comment) : self
Parameters
- $comment : string|null
Return values
self —setPrimaryKey()
Sets the Primary Key.
public
setPrimaryKey(array<string|int, string> $columnNames[, string|false $indexName = false ]) : self
Parameters
- $columnNames : array<string|int, string>
- $indexName : string|false = false
Tags
Return values
self —setSchemaConfig()
public
setSchemaConfig(SchemaConfig $schemaConfig) : void
Parameters
- $schemaConfig : SchemaConfig
Return values
void —visit()
public
visit(Visitor $visitor) : void
Parameters
- $visitor : Visitor
Tags
Return values
void —_addColumn()
protected
_addColumn(Column $column) : void
Parameters
- $column : Column
Tags
Return values
void —_addForeignKeyConstraint()
protected
_addForeignKeyConstraint(ForeignKeyConstraint $constraint) : self
Parameters
- $constraint : ForeignKeyConstraint
Return values
self —_addIndex()
Adds an index to the table.
protected
_addIndex(Index $indexCandidate) : self
Parameters
- $indexCandidate : Index
Tags
Return values
self —_addUniqueConstraint()
protected
_addUniqueConstraint(UniqueConstraint $constraint) : self
Parameters
- $constraint : UniqueConstraint
Return values
self —_generateIdentifierName()
Generates an identifier from a list of column names obeying a certain string length.
protected
_generateIdentifierName(array<string|int, string> $columnNames[, string $prefix = '' ][, int $maxSize = 30 ]) : string
This is especially important for Oracle, since it does not allow identifiers larger than 30 chars, however building idents automatically for foreign keys, composite keys or such can easily create very long names.
Parameters
- $columnNames : array<string|int, string>
- $prefix : string = ''
- $maxSize : int = 30
Return values
string —_getMaxIdentifierLength()
protected
_getMaxIdentifierLength() : int
Return values
int —_setName()
Sets the name of this asset.
protected
_setName(string $name) : void
Parameters
- $name : string
Return values
void —isIdentifierQuoted()
Checks if this identifier is quoted.
protected
isIdentifierQuoted(string $identifier) : bool
Parameters
- $identifier : string
Return values
bool —trimQuotes()
Trim quotes from the identifier.
protected
trimQuotes(string $identifier) : string
Parameters
- $identifier : string
Return values
string —_createIndex()
private
_createIndex(array<string|int, string> $columnNames, string $indexName, bool $isUnique, bool $isPrimary[, array<string|int, string> $flags = [] ][, array<string|int, mixed> $options = [] ]) : Index
Parameters
- $columnNames : array<string|int, string>
- $indexName : string
- $isUnique : bool
- $isPrimary : bool
- $flags : array<string|int, string> = []
- $options : array<string|int, mixed> = []
Tags
Return values
Index —_createUniqueConstraint()
private
_createUniqueConstraint(array<string|int, string> $columnNames, string $indexName[, array<string|int, string> $flags = [] ][, array<string|int, mixed> $options = [] ]) : UniqueConstraint
Parameters
- $columnNames : array<string|int, string>
- $indexName : string
- $flags : array<string|int, string> = []
- $options : array<string|int, mixed> = []
Tags
Return values
UniqueConstraint —filterColumns()
Returns only columns that have specified names
private
filterColumns(array<string|int, string> $columnNames[, bool $reverse = false ]) : array<string|int, Column>
Parameters
- $columnNames : array<string|int, string>
- $reverse : bool = false
Return values
array<string|int, Column> —normalizeIdentifier()
Normalizes a given identifier.
private
normalizeIdentifier(string|null $identifier) : string
Trims quotes and lowercases the given identifier.
Parameters
- $identifier : string|null
Return values
string —The normalized identifier.