class Table extends AbstractAsset (View source)

Object Representation of a table.

Properties

protected string $_name
protected string|null $_namespace Namespace of the asset. If none isset the default namespace is assumed. from AbstractAsset
protected bool $_quoted from AbstractAsset
protected Column[] $_columns
protected Index[] $_indexes
protected string $_primaryKeyName
protected ForeignKeyConstraint[] $_fkConstraints
protected array $_options
protected SchemaConfig|null $_schemaConfig

Methods

void
_setName(string $name)

Sets the name of this asset.

bool
isInDefaultNamespace(string $defaultNamespaceName)

Is this asset in the default namespace?

string|null
getNamespaceName()

Gets the namespace name of this asset.

string
getShortestName(string $defaultNamespaceName)

The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.

string
getFullQualifiedName(string $defaultNamespaceName)

The normalized name is full-qualified and lowerspaced. Lowerspacing 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.

bool
isQuoted()

Checks if this asset's name is quoted.

bool
isIdentifierQuoted(string $identifier)

Checks if this identifier is quoted.

string
trimQuotes(string $identifier)

Trim quotes from the identifier.

string
getName()

Returns the name of this schema asset.

string
getQuotedName(AbstractPlatform $platform)

Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.

string
_generateIdentifierName(array $columnNames, string $prefix = '', int $maxSize = 30)

Generates an identifier from a list of column names obeying a certain string length.

__construct(string $tableName, array $columns = [], array $indexes = [], array $fkConstraints = [], int $idGeneratorType = 0, array $options = [])

No description

void
setSchemaConfig(SchemaConfig $schemaConfig)

No description

int
_getMaxIdentifierLength()

No description

setPrimaryKey(array $columns, string|boolean $indexName = false)

Sets the Primary Key.

addIndex(array $columnNames, string|null $indexName = null, array $flags = [], array $options = [])

No description

void
dropPrimaryKey()

Drops the primary key from this table.

void
dropIndex(string $indexName)

Drops an index from this table.

addUniqueIndex(array $columnNames, string|null $indexName = null, array $options = [])

No description

renameIndex(string $oldIndexName, string|null $newIndexName = null)

Renames an index.

bool
columnsAreIndexed(array $columnsNames)

Checks if an index begins in the order of the given columns.

addColumn(string $columnName, string $typeName, array $options = [])

No description

renameColumn(string $oldColumnName, string $newColumnName) deprecated

Renames a Column.

changeColumn(string $columnName, array $options)

Change Column Details.

dropColumn(string $columnName)

Drops a Column from the Table.

addForeignKeyConstraint(Table|string $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [], string|null $constraintName = null)

Adds a foreign key constraint.

addUnnamedForeignKeyConstraint(Table|string $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = []) deprecated

Adds a foreign key constraint.

addNamedForeignKeyConstraint(string $name, Table|string $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = []) deprecated

Adds a foreign key constraint with a given name.

addOption(string $name, string $value)

No description

void
_addColumn(Column $column)

No description

_addIndex(Index $indexCandidate)

Adds an index to the table.

void
_addForeignKeyConstraint(ForeignKeyConstraint $constraint)

No description

bool
hasForeignKey(string $constraintName)

Returns whether this table has a foreign key constraint with the given name.

getForeignKey(string $constraintName)

Returns the foreign key constraint with the given name.

void
removeForeignKey(string $constraintName)

Removes the foreign key constraint with the given name.

Column[]
getColumns()

Returns ordered list of columns (primary keys are first, then foreign keys, then the rest)

bool
hasColumn(string $columnName)

Returns whether this table has a Column with the given name.

getColumn(string $columnName)

Returns the Column with the given name.

Index|null
getPrimaryKey()

Returns the primary key.

array
getPrimaryKeyColumns()

Returns the primary key columns.

bool
hasPrimaryKey()

Returns whether this table has a primary key.

bool
hasIndex(string $indexName)

Returns whether this table has an Index with the given name.

getIndex(string $indexName)

Returns the Index with the given name.

Index[]
getIndexes()

No description

getForeignKeys()

Returns the foreign key constraints.

bool
hasOption(string $name)

No description

mixed
getOption(string $name)

No description

array
getOptions()

No description

void
visit(Visitor $visitor)

No description

void
__clone()

Clone of a Table triggers a deep clone of all affected assets.

Details

protected void _setName(string $name)

Sets the name of this asset.

Parameters

string $name

Return Value

void

bool isInDefaultNamespace(string $defaultNamespaceName)

Is this asset in the default namespace?

Parameters

string $defaultNamespaceName

Return Value

bool

string|null getNamespaceName()

Gets the namespace name of this asset.

If NULL is returned this means the default namespace is used.

Return Value

string|null

string getShortestName(string $defaultNamespaceName)

The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.

Parameters

string $defaultNamespaceName

Return Value

string

string getFullQualifiedName(string $defaultNamespaceName)

The normalized name is full-qualified and lowerspaced. Lowerspacing 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.

Every non-namespaced element is prefixed with the default namespace name which is passed as argument to this method.

Parameters

string $defaultNamespaceName

Return Value

string

bool isQuoted()

Checks if this asset's name is quoted.

Return Value

bool

protected bool isIdentifierQuoted(string $identifier)

Checks if this identifier is quoted.

Parameters

string $identifier

Return Value

bool

protected string trimQuotes(string $identifier)

Trim quotes from the identifier.

Parameters

string $identifier

Return Value

string

string getName()

Returns the name of this schema asset.

Return Value

string

string getQuotedName(AbstractPlatform $platform)

Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.

Parameters

AbstractPlatform $platform

Return Value

string

protected string _generateIdentifierName(array $columnNames, string $prefix = '', int $maxSize = 30)

Generates an identifier from a list of column names obeying a certain string length.

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

array $columnNames
string $prefix
int $maxSize

Return Value

string

__construct(string $tableName, array $columns = [], array $indexes = [], array $fkConstraints = [], int $idGeneratorType = 0, array $options = [])

Parameters

string $tableName
array $columns
array $indexes
array $fkConstraints
int $idGeneratorType
array $options

Exceptions

DBALException

void setSchemaConfig(SchemaConfig $schemaConfig)

Parameters

SchemaConfig $schemaConfig

Return Value

void

protected int _getMaxIdentifierLength()

Return Value

int

Table setPrimaryKey(array $columns, string|boolean $indexName = false)

Sets the Primary Key.

Parameters

array $columns
string|boolean $indexName

Return Value

Table

Table addIndex(array $columnNames, string|null $indexName = null, array $flags = [], array $options = [])

Parameters

array $columnNames
string|null $indexName
array $flags
array $options

Return Value

Table

void dropPrimaryKey()

Drops the primary key from this table.

Return Value

void

void dropIndex(string $indexName)

Drops an index from this table.

Parameters

string $indexName The index name.

Return Value

void

Exceptions

SchemaException If the index does not exist.

Table addUniqueIndex(array $columnNames, string|null $indexName = null, array $options = [])

Parameters

array $columnNames
string|null $indexName
array $options

Return Value

Table

Table renameIndex(string $oldIndexName, string|null $newIndexName = null)

Renames an index.

Parameters

string $oldIndexName The name of the index to rename from.
string|null $newIndexName The name of the index to rename to. If null is given, the index name will be auto-generated.

Return Value

Table This table instance.

Exceptions

SchemaException if no index exists for the given current name or if an index with the given new name already exists on this table.

bool columnsAreIndexed(array $columnsNames)

Checks if an index begins in the order of the given columns.

Parameters

array $columnsNames

Return Value

bool

Column addColumn(string $columnName, string $typeName, array $options = [])

Parameters

string $columnName
string $typeName
array $options

Return Value

Column

renameColumn(string $oldColumnName, string $newColumnName) deprecated

deprecated

Renames a Column.

Parameters

string $oldColumnName
string $newColumnName

Exceptions

DBALException

Table changeColumn(string $columnName, array $options)

Change Column Details.

Parameters

string $columnName
array $options

Return Value

Table

Table dropColumn(string $columnName)

Drops a Column from the Table.

Parameters

string $columnName

Return Value

Table

Table addForeignKeyConstraint(Table|string $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [], string|null $constraintName = null)

Adds a foreign key constraint.

Name is inferred from the local columns.

Parameters

Table|string $foreignTable Table schema instance or table name
array $localColumnNames
array $foreignColumnNames
array $options
string|null $constraintName

Return Value

Table

Table addUnnamedForeignKeyConstraint(Table|string $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = []) deprecated

deprecated Use {@link addForeignKeyConstraint}

Adds a foreign key constraint.

Name is to be generated by the database itself.

Parameters

Table|string $foreignTable Table schema instance or table name
array $localColumnNames
array $foreignColumnNames
array $options

Return Value

Table

Table addNamedForeignKeyConstraint(string $name, Table|string $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = []) deprecated

deprecated Use {@link addForeignKeyConstraint}

Adds a foreign key constraint with a given name.

Parameters

string $name
Table|string $foreignTable Table schema instance or table name
array $localColumnNames
array $foreignColumnNames
array $options

Return Value

Table

Exceptions

SchemaException

Table addOption(string $name, string $value)

Parameters

string $name
string $value

Return Value

Table

protected void _addColumn(Column $column)

Parameters

Column $column

Return Value

void

Exceptions

SchemaException

protected Table _addIndex(Index $indexCandidate)

Adds an index to the table.

Parameters

Index $indexCandidate

Return Value

Table

Exceptions

SchemaException

protected void _addForeignKeyConstraint(ForeignKeyConstraint $constraint)

Parameters

ForeignKeyConstraint $constraint

Return Value

void

bool hasForeignKey(string $constraintName)

Returns whether this table has a foreign key constraint with the given name.

Parameters

string $constraintName

Return Value

bool

ForeignKeyConstraint getForeignKey(string $constraintName)

Returns the foreign key constraint with the given name.

Parameters

string $constraintName The constraint name.

Return Value

ForeignKeyConstraint

Exceptions

SchemaException If the foreign key does not exist.

void removeForeignKey(string $constraintName)

Removes the foreign key constraint with the given name.

Parameters

string $constraintName The constraint name.

Return Value

void

Exceptions

SchemaException

Column[] getColumns()

Returns ordered list of columns (primary keys are first, then foreign keys, then the rest)

Return Value

Column[]

bool hasColumn(string $columnName)

Returns whether this table has a Column with the given name.

Parameters

string $columnName The column name.

Return Value

bool

Column getColumn(string $columnName)

Returns the Column with the given name.

Parameters

string $columnName The column name.

Return Value

Column

Exceptions

SchemaException If the column does not exist.

Index|null getPrimaryKey()

Returns the primary key.

Return Value

Index|null The primary key, or null if this Table has no primary key.

array getPrimaryKeyColumns()

Returns the primary key columns.

Return Value

array

Exceptions

DBALException

bool hasPrimaryKey()

Returns whether this table has a primary key.

Return Value

bool

bool hasIndex(string $indexName)

Returns whether this table has an Index with the given name.

Parameters

string $indexName The index name.

Return Value

bool

Index getIndex(string $indexName)

Returns the Index with the given name.

Parameters

string $indexName The index name.

Return Value

Index

Exceptions

SchemaException If the index does not exist.

Index[] getIndexes()

Return Value

Index[]

ForeignKeyConstraint[] getForeignKeys()

Returns the foreign key constraints.

Return Value

ForeignKeyConstraint[]

bool hasOption(string $name)

Parameters

string $name

Return Value

bool

mixed getOption(string $name)

Parameters

string $name

Return Value

mixed

array getOptions()

Return Value

array

void visit(Visitor $visitor)

Parameters

Visitor $visitor

Return Value

void

void __clone()

Clone of a Table triggers a deep clone of all affected assets.

Return Value

void